Package org.djunits.unit
Class TimeUnit
- All Implemented Interfaces:
Serializable
,Cloneable
Standard absolute time units. Note that when the offset of a stored absolute Time becomes large, precision of a float or
double might not be enough for the required resolution of a Time. A float has around 7 significant digits (23 bit mantissa),
whereas a double has around 16 significant digits (52 bit mantissa). This means that when we need to have a float time that
is precise to microseconds, the Time value should not go above 2^22 = 4.0E6. This is not enough to store Epoch values!
So feeding System.TimeInMillis() to a FloatTime with TimeUnit.BASE as its unit is not having the required precision. For 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 on an Epoch level precise to a ms.
Copyright (c) 2015-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUNITS License.
- Author:
- Alexander Verbraeck
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.djunits.unit.AbsoluteLinearUnit
AbsoluteLinearUnit.Builder<AU extends AbsoluteLinearUnit<AU,
RU>, RU extends Unit<RU>> -
Field Summary
Modifier and TypeFieldDescriptionThe base, with "m2" as the SI signature.static final TimeUnit
The base unit for time with an artificial "zero" point with a calculation in days.static final TimeUnit
The base unit for time with an artificial "zero" point with a calculation in hours.static final TimeUnit
The base unit for time with an artificial "zero" point with a calculation in microseconds.static final TimeUnit
The base unit for time with an artificial "zero" point with a calculation in milliseconds.static final TimeUnit
The base unit for time with an artificial "zero" point with a calculation in minutes.static final TimeUnit
The base unit for time with an artifical "zero" point with a calculation in seconds.static final TimeUnit
The base unit for time with an artificial "zero" point with a calculation in weeks.static final TimeUnit
The default unit for time is BASE_SECOND.static final TimeUnit
The POSIX and Gregorian Epoch: January 1, 1970 at 00:00 UTC with a calculation in days.static final TimeUnit
The POSIX and Gregorian Epoch: January 1, 1970 at 00:00 UTC with a calculation in hours.static final TimeUnit
The Epoch with J2000.0 as the origin, which is The Gregorian date January 1, 2000 at 12:00 GMT (noon) with a calculation in seconds.static final TimeUnit
The POSIX and Gregorian Epoch: January 1, 1970 at 00:00 UTC with a calculation in microseconds.static final TimeUnit
The POSIX and Gregorian Epoch: January 1, 1970 at 00:00 UTC with a calculation in milliseconds.static final TimeUnit
The POSIX and Gregorian Epoch: January 1, 1970 at 00:00 UTC with a calculation in minutes.static final TimeUnit
The POSIX and Gregorian Epoch: January 1, 1970 at 00:00 UTC with a calculation in seconds.static final TimeUnit
The POSIX and Gregorian Epoch: January 1, 1970 at 00:00 UTC with a calculation in weeks.static final TimeUnit
The Epoch with 0001-01-01 AD at 00:00 as the origin with a calculation in seconds. -
Constructor Summary
-
Method Summary
Methods inherited from class org.djunits.unit.AbsoluteLinearUnit
build, deriveLinearOffset, deriveLinearOffset, deriveLinearOffset, getRelativeQuantity, getRelativeUnit, getScale, makeBuilder
Methods inherited from class org.djunits.unit.Unit
clone, deriveLinear, deriveLinear, deriveLinear, derivePerSI, deriveSI, deriveSI, deriveSIKilo, equals, getDefaultAbbreviations, getDefaultDisplayAbbreviation, getDefaultTextualAbbreviation, getId, getLocalizedAbbreviations, getLocalizedDisplayAbbreviation, getLocalizedTextualAbbreviation, getName, getQuantity, getStandardUnit, getUnit, getUnitSystem, hashCode, isBaseSIUnit, isGenerated, lookupOrCreateUnitWithSIDimensions, toString
-
Field Details
-
BASE
The base, with "m2" as the SI signature. -
BASE_SECOND
The base unit for time with an artifical "zero" point with a calculation in seconds. Note that when the offset becomes large, precision of a float or double might not be enough for the required resolution of a Time. A float has around 7 significant digits (23 bit mantissa), whereas a double has around 16 significant digits (52 bit mantissa). This means that when we need to have a float time that is precise to microseconds, the Time value should not go above 2^22 = 4.0E6. This is not enough to store Epoch values! So feeding System.TimeInMillis() to a FloatTime with TimeUnit.BASE as its unit is not having the required precision. For 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 on an Epoch level precise to a ms. -
DEFAULT
The default unit for time is BASE_SECOND. -
BASE_MICROSECOND
The base unit for time with an artificial "zero" point with a calculation in microseconds. -
BASE_MILLISECOND
The base unit for time with an artificial "zero" point with a calculation in milliseconds. -
BASE_MINUTE
The base unit for time with an artificial "zero" point with a calculation in minutes. -
BASE_HOUR
The base unit for time with an artificial "zero" point with a calculation in hours. -
BASE_DAY
The base unit for time with an artificial "zero" point with a calculation in days. -
BASE_WEEK
The base unit for time with an artificial "zero" point with a calculation in weeks. -
EPOCH_SECOND
The POSIX and Gregorian Epoch: January 1, 1970 at 00:00 UTC with a calculation in seconds. The base should be taken in such a way that a resolution of a millisecond is still 'visible' on a date in, say, 2020. When 1-1-1970 is used as the origin, 1-1-2021 has a value of 1,577,836,800,000 milliseconds = 1.6E12 ms. If we want to be precise on the ms level, we need 12 significant digits. A float has around 7 significant digits (23 bit mantissa), whereas a double has around 16 significant digits (52 bit mantissa). This means that a float time with an offset of 1-1-1970 is at best precise to a minute level. A double time is precise to microseconds. Therefore, avoid using float times that use the EPOCH. -
EPOCH_MICROSECOND
The POSIX and Gregorian Epoch: January 1, 1970 at 00:00 UTC with a calculation in microseconds. -
EPOCH_MILLISECOND
The POSIX and Gregorian Epoch: January 1, 1970 at 00:00 UTC with a calculation in milliseconds. -
EPOCH_MINUTE
The POSIX and Gregorian Epoch: January 1, 1970 at 00:00 UTC with a calculation in minutes. -
EPOCH_HOUR
The POSIX and Gregorian Epoch: January 1, 1970 at 00:00 UTC with a calculation in hours. -
EPOCH_DAY
The POSIX and Gregorian Epoch: January 1, 1970 at 00:00 UTC with a calculation in days. -
EPOCH_WEEK
The POSIX and Gregorian Epoch: January 1, 1970 at 00:00 UTC with a calculation in weeks. -
EPOCH_YEAR1_SECOND
The Epoch with 0001-01-01 AD at 00:00 as the origin with a calculation in seconds. When 1-1-0001 is used as the origin, 1-1-2021 has a value of around 6.4E13 ms. If we want to be precise on the ms level, we need 13 significant digits. A float has around 7 significant digits (23 bit mantissa), whereas a double has around 16 significant digits (52 bit mantissa). This means that a float time with an offset of 1-1-0001 is at best precise to an hour level. A double time is precise to microseconds. Therefore, avoid using float times that use the EPOCH_YEAR1_SECOND. -
EPOCH_J2000_SECOND
The Epoch with J2000.0 as the origin, which is The Gregorian date January 1, 2000 at 12:00 GMT (noon) with a calculation in seconds. When 1-1-2000 is used as the origin, 1-1-2021 has a value of around 6.3E11 ms. If we want to be precise on the ms level, we need 11 significant digits. A float has around 7 significant digits (23 bit mantissa), whereas a double has around 16 significant digits (52 bit mantissa). This means that a float time with an offset of 1-1-2000 is at best precise to a minute level. A double time is precise to fractions of microseconds. Therefore, avoid using float times that use the EPOCH_J2000_SECOND.
-
-
Constructor Details
-
TimeUnit
public TimeUnit()
-