1 package org.opentrafficsim.core.unit;
2
3 import static org.opentrafficsim.core.unit.unitsystem.UnitSystem.OTHER;
4 import static org.opentrafficsim.core.unit.unitsystem.UnitSystem.SI_ACCEPTED;
5 import static org.opentrafficsim.core.unit.unitsystem.UnitSystem.SI_BASE;
6
7 import org.opentrafficsim.core.unit.unitsystem.UnitSystem;
8
9
10
11
12
13
14
15
16
17
18 public class TimeUnit extends Unit<TimeUnit>
19 {
20
21 private static final long serialVersionUID = 20140607L;
22
23
24 public static final TimeUnit SI;
25
26
27 public static final TimeUnit SECOND;
28
29
30 public static final TimeUnit MILLISECOND;
31
32
33 public static final TimeUnit MINUTE;
34
35
36 public static final TimeUnit HOUR;
37
38
39 public static final TimeUnit DAY;
40
41
42 public static final TimeUnit WEEK;
43
44 static
45 {
46 SI = new TimeUnit("TimeUnit.second", "TimeUnit.s", SI_BASE);
47 SECOND = SI;
48 MILLISECOND = new TimeUnit("TimeUnit.millisecond", "TimeUnit.ms", SI_BASE, SECOND, 0.001);
49 MINUTE = new TimeUnit("TimeUnit.minute", "TimeUnit.m", SI_ACCEPTED, SECOND, 60.0);
50 HOUR = new TimeUnit("TimeUnit.hour", "TimeUnit.h", SI_ACCEPTED, MINUTE, 60.0);
51 DAY = new TimeUnit("TimeUnit.day", "TimeUnit.d", SI_ACCEPTED, HOUR, 24.0);
52 WEEK = new TimeUnit("TimeUnit.week", "TimeUnit.w", OTHER, DAY, 7.0);
53 }
54
55
56
57
58
59
60
61 public TimeUnit(final String nameKey, final String abbreviationKey, final UnitSystem unitSystem)
62 {
63 super(nameKey, abbreviationKey, unitSystem, true);
64 }
65
66
67
68
69
70
71
72
73
74
75 public TimeUnit(final String nameKey, final String abbreviationKey, final UnitSystem unitSystem,
76 final TimeUnit referenceUnit, final double conversionFactorToReferenceUnit)
77 {
78 super(nameKey, abbreviationKey, unitSystem, referenceUnit, conversionFactorToReferenceUnit, true);
79 }
80
81
82 @Override
83 public final TimeUnit getStandardUnit()
84 {
85 return SECOND;
86 }
87
88
89 @Override
90 public final String getSICoefficientsString()
91 {
92 return "s";
93 }
94
95 }