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.
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.
Copyright (c) 2013-2018 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands.
All rights reserved.
BSD-style license. See OpenTrafficSim License.
$LastChangedDate: 2018-01-28 03:17:44 +0100 (Sun, 28 Jan 2018) $, @version $Revision: 256 $, by $Author: averbraeck $,
initial version Sep 1, 2015
| Modifier and Type | Field and Description |
|---|---|
static Time |
ZERO
constant with value zero.
|
si| 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.
|
ceil, divideBy, floor, minus, minus, multiplyBy, plus, rint, roundcompareTo, doubleValue, eq, eq0, equals, floatValue, ge, ge0, getInUnit, getInUnit, getSI, gt, gt0, hashCode, intValue, le, le0, longValue, lt, lt0, ne, ne0, toString, toString, toString, toStringexpressAsSIUnit, expressAsSpecifiedUnit, getUnit, isAbsolute, isRelative, setDisplayUnitbyteValue, shortValueclone, finalize, getClass, notify, notifyAll, wait, wait, waitDIV, MULT, POWpublic 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 - the double valueunit - the unitpublic final Duration instantiateRel(double value, DurationUnit unit)
instantiateRel in class AbstractDoubleScalarAbs<TimeUnit,Time,DurationUnit,Duration>value - the double valueunit - 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 scalarCopyright © 2015–2018 Delft University of Technology. All rights reserved.