public class Time extends AbstractDoubleScalarAbs<TimeUnit,Time,DurationUnit,Duration>
DoubleScalar.Abs<TimeUnit> value = new DoubleScalar.Abs<TimeUnit>(100.0, TimeUnit.SI);we can now write:
Time value = new Time(100.0, TimeUnit.BASE);The compiler will automatically recognize which units belong to which quantity, and whether the quantity type and the unit used are compatible.
Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands.
All rights reserved.
BSD-style license. See OpenTrafficSim License.
Note that when the offset of a stored absolute Time becomes large, precision of a double might not be enough for the required resolution of a Time. A double has around 16 significant digits (52 bit mantissa). This means that when we need to have a double Time with TimeUnit.BASE as its unit, the largest value where the ms precision is reached is 2^51 = 2.3E15, which is around 71000 years. This is sufficient to store a date in the 21st Century with a BASE or an Epoch offset precise to a microsecond.
$LastChangedDate: 2019-03-03 00:53:50 +0100 (Sun, 03 Mar 2019) $, @version $Revision: 349 $, by $Author: averbraeck $,
initial version Sep 1, 2015
Modifier and Type | Field and Description |
---|---|
static Time |
ZERO
constant with value zero.
|
si
NUMBER_PATTERN
Constructor and Description |
---|
Time(double value,
TimeUnit unit)
Construct Time scalar.
|
Time(Time value)
Construct Time scalar.
|
Modifier and Type | Method and Description |
---|---|
static Time |
createSI(double value)
Construct %TypeAbsl% scalar.
|
Time |
instantiateAbs(double value,
TimeUnit unit)
Construct a new Absolute Immutable DoubleScalar of the right type.
|
Duration |
instantiateRel(double value,
DurationUnit unit)
Construct a new Relative Immutable DoubleScalar of the right type.
|
static Time |
interpolate(Time zero,
Time one,
double ratio)
Interpolate between two values.
|
static Time |
max(Time a1,
Time a2)
Return the maximum value of two absolute scalars.
|
static Time |
max(Time a1,
Time a2,
Time... an)
Return the maximum value of more than two absolute scalars.
|
static Time |
min(Time a1,
Time a2)
Return the minimum value of two absolute scalars.
|
static Time |
min(Time a1,
Time a2,
Time... an)
Return the minimum value of more than two absolute scalars.
|
static Time |
valueOf(String text)
Returns a Time representation of a textual representation of a value with a unit.
|
ceil, divideBy, floor, minus, minus, multiplyBy, plus, rint, round
compareTo, doubleValue, eq, eq0, equals, floatValue, ge, ge0, getInUnit, getInUnit, getSI, gt, gt0, hashCode, intValue, le, le0, longValue, lt, lt0, ne, ne0, toString, toString, toString, toString
expressAsSIUnit, expressAsSpecifiedUnit, getUnit, isAbsolute, isRelative, setDisplayUnit, stringOf, stringOfDefaultLocale, textualStringOf, textualStringOfDefaultLocale
byteValue, shortValue
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
DIV, MULT, POW
public static final Time ZERO
public Time(double value, TimeUnit unit)
value
- double valueunit
- unit for the double valuepublic Time(Time value)
value
- Scalar from which to construct this instancepublic final Time instantiateAbs(double value, TimeUnit unit)
instantiateAbs
in class AbstractDoubleScalarAbs<TimeUnit,Time,DurationUnit,Duration>
value
- double; the double valueunit
- AU; the unitpublic final Duration instantiateRel(double value, DurationUnit unit)
instantiateRel
in class AbstractDoubleScalarAbs<TimeUnit,Time,DurationUnit,Duration>
value
- double; the double valueunit
- RU; the unitpublic static final Time createSI(double value)
value
- double value in SI unitspublic static Time interpolate(Time zero, Time one, double ratio)
zero
- the low valueone
- the high valueratio
- the ratio between 0 and 1, inclusivepublic static Time max(Time a1, Time a2)
a1
- the first scalara2
- the second scalarpublic static Time max(Time a1, Time a2, Time... an)
a1
- the first scalara2
- the second scalaran
- the other scalarspublic static Time min(Time a1, Time a2)
a1
- the first scalara2
- the second scalarpublic static Time min(Time a1, Time a2, Time... an)
a1
- the first scalara2
- the second scalaran
- the other scalarspublic static Time valueOf(String text) throws IllegalArgumentException
text
- String; the textual representation to parse into a TimeIllegalArgumentException
- when the text cannot be parsedCopyright © 2015–2019 Delft University of Technology. All rights reserved.