Package org.djunits.quantity
Class Time
java.lang.Object
java.lang.Number
org.djunits.quantity.def.AbsoluteQuantity<Time,Duration,Duration.Unit,Time.Reference>
org.djunits.quantity.Time
- All Implemented Interfaces:
Serializable,Comparable<Time>,Value<Duration.Unit,Time>
Time is the absolute equivalent of Duration, and can, e.g., represent a calendar date with a zero. Note that built-in time
references are independent; DJUNITS does not embed calendar calculations.
Copyright (c) 2025-2026 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djunits.org. The DJUNITS project is distributed under a three-clause BSD-style license.
- Author:
- Alexander Verbraeck
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classThe reference class to define a reference point for the time. -
Constructor Summary
ConstructorsConstructorDescriptionTime(double value, String abbreviation, Time.Reference reference) Instantiate a Time quantity with a unit, expressed as a String, and a reference point.Time(double value, Duration.Unit unit, Time.Reference reference) Instantiate a Time quantity with a unit and a reference point.Time(Duration duration, Time.Reference reference) Instantiate a Time instance based on an duration and a reference point. -
Method Summary
Modifier and TypeMethodDescriptionAdd a relative quantity to this absolute quantity, resulting in a new absolute quantity containing the sum.instantiate(Duration duration, Time.Reference reference) Instantiate an absolute quantity with a quantity and a reference.static Timeof(double value, String unitString, Time.Reference reference) Returns a Time based on a value and the textual representation of the unit, which can be localized.static TimeofSi(double si, Time.Reference reference) Return a Time instance based on an SI value and a reference point.siUnit()Return the SI unit of this quantity.Subtract a relative quantity from this absolute quantity, resulting in a new absolute quantity containing the difference.Subtract two absolute quantities from each other, resulting in the corresponding relative quantity.static TimevalueOf(String text, Time.Reference reference) Returns a Time representation of a textual representation of a value with a unit.Methods inherited from class org.djunits.quantity.def.AbsoluteQuantity
compareTo, doubleValue, eq, eq0, equals, floatValue, format, format, ge, ge0, getDisplayUnit, getInUnit, getInUnit, getName, getQuantity, getReference, gt, gt0, hashCode, interpolate, intValue, isRelative, le, le0, longValue, lt, lt0, max, mean, min, ne, ne0, of, relativeTo, setDisplayUnit, si, sum, toDisplayString, toDisplayString, toString, toString, toString, toString, toStringSIPrefixed, toStringSIPrefixed, toTextualString, toTextualString, valueOfMethods inherited from class java.lang.Number
byteValue, shortValueMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.djunits.value.Value
isAbsolute, setDisplayUnit
-
Constructor Details
-
Time
Instantiate a Time quantity with a unit and a reference point.- Parameters:
value- the duration value, expressed in a duration unitunit- the duration unit in which the value is expressed, relative to the reference pointreference- the reference point of this time
-
Time
Instantiate a Time quantity with a unit, expressed as a String, and a reference point.- Parameters:
value- the duration value, expressed in the unit, relative to the reference pointabbreviation- the String abbreviation of the unit in which the value is expressedreference- the reference point of this time
-
Time
Instantiate a Time instance based on an duration and a reference point.- Parameters:
duration- the duration, relative to the reference pointreference- the reference point of this time
-
-
Method Details
-
ofSi
Return a Time instance based on an SI value and a reference point.- Parameters:
si- the duration si value, relative to the reference pointreference- the reference point of this time- Returns:
- the Time instance based on an SI value
-
instantiate
Description copied from class:AbsoluteQuantityInstantiate an absolute quantity with a quantity and a reference.- Specified by:
instantiatein classAbsoluteQuantity<Time,Duration, Duration.Unit, Time.Reference> - Parameters:
duration- the relative quantity that indicates the 'distance' to the reference pointreference- the reference point- Returns:
- the absolute quantity with a quantity and a reference
-
siUnit
Description copied from class:AbsoluteQuantityReturn the SI unit of this quantity.- Overrides:
siUnitin classAbsoluteQuantity<Time,Duration, Duration.Unit, Time.Reference> - Returns:
- the SI unit of this quantity
-
valueOf
Returns a Time representation of a textual representation of a value with a unit. The String representation that can be parsed is the double value in the unit, followed by a localized or English abbreviation of the unit. Spaces are allowed, but not required, between the value and the unit.- Parameters:
text- the textual representation to parse into a Timereference- the reference point of this time- Returns:
- the Scalar representation of the value in its unit
- Throws:
IllegalArgumentException- when the text cannot be parsedNullPointerException- when the text argument is null
-
of
Returns a Time based on a value and the textual representation of the unit, which can be localized.- Parameters:
value- the value to useunitString- the textual representation of the unitreference- the reference point of this time- Returns:
- the Scalar representation of the value in its unit
- Throws:
IllegalArgumentException- when the unit cannot be parsed or is incorrectNullPointerException- when the unitString argument is null
-
subtract
Description copied from class:AbsoluteQuantitySubtract two absolute quantities from each other, resulting in the corresponding relative quantity. The unit of the resulting quantity will be the unit of 'this' absolute quantity. Quantity 'other' will be transformed to the reference point of this absolute quantity. If the reference points of this and other are different, and no transformations between the reference points exist, an exception will be thrown.- Specified by:
subtractin classAbsoluteQuantity<Time,Duration, Duration.Unit, Time.Reference> - Parameters:
other- the absolute quantity to subtract- Returns:
- the relative quantity as a result of the subtraction
-
add
Description copied from class:AbsoluteQuantityAdd a relative quantity to this absolute quantity, resulting in a new absolute quantity containing the sum. The new quantity will have the same reference point and unit as this absolute quantity.- Specified by:
addin classAbsoluteQuantity<Time,Duration, Duration.Unit, Time.Reference> - Parameters:
other- the relative quantity to add- Returns:
- the absolute quantity as a result of the addition
-
subtract
Description copied from class:AbsoluteQuantitySubtract a relative quantity from this absolute quantity, resulting in a new absolute quantity containing the difference. The new quantity will have the same reference point and unit as this absolute quantity.- Specified by:
subtractin classAbsoluteQuantity<Time,Duration, Duration.Unit, Time.Reference> - Parameters:
other- the relative quantity to subtract- Returns:
- the absolute quantity as a result of the subtraction
-