-
Notifications
You must be signed in to change notification settings - Fork 205
Expand file tree
/
Copy pathTimeUnitUtils.java
More file actions
67 lines (54 loc) · 2 KB
/
TimeUnitUtils.java
File metadata and controls
67 lines (54 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package com.example.task03;
/**
* Класс, в котором собраны методы для работы с {@link TimeUnit}
*/
public class TimeUnitUtils {
/**
* Конвертирует интервал в секундах в интервал в миллисекундах
*
* @param seconds интервал в секундах
* @return интервал в миллисекундах
*/
public static Milliseconds toMillis(Seconds seconds) {
return new Milliseconds(seconds.toMillis());
}
public static Milliseconds toMillis(Minutes minutes) {
return new Milliseconds(minutes.toMillis());
}
public static Milliseconds toMillis(Hours hours) {
return new Milliseconds(hours.toMillis());
}
/**
* Конвертирует интервал в миллисекундах в интервал в секундах
*
* @param millis интервал в миллисекундах
* @return интервал в секундах
*/
public static Seconds toSeconds(Milliseconds millis) {
return new Seconds(millis.toSeconds());
}
public static Seconds toSeconds(Minutes minutes) {
return new Seconds(minutes.toSeconds());
}
public static Seconds toSeconds(Hours hours) {
return new Seconds(hours.toSeconds());
}
public static Minutes toMinutes(Milliseconds milliseconds) {
return new Minutes(milliseconds.toMinutes());
}
public static Minutes toMinutes(Seconds seconds) {
return new Minutes(seconds.toMinutes());
}
public static Minutes toMinutes(Hours hours) {
return new Minutes(hours.toMinutes());
}
public static Hours toHours(Milliseconds milliseconds) {
return new Hours(milliseconds.getHours());
}
public static Hours toHours(Seconds seconds) {
return new Hours(seconds.getHours());
}
public static Hours toHours(Minutes minutes) {
return new Hours(minutes.getHours());
}
}