- All Implemented Interfaces:
Serializable,Cloneable,Comparable<DimensionedValue<Time>>,Formattable,DimensionedValue<Time>
@ClassVersion(sourceVersion="$Id: TimeValue.java 1073 2023-10-01 11:08:51Z tquadrat $")
@API(status=STABLE,
since="0.1.0")
public final class TimeValue
extends ValueBase<Time,TimeValue>
A value class for times, what means periods of time in this
case, opposite to the time displayed on the wall-clock.
- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: TimeValue.java 1073 2023-10-01 11:08:51Z tquadrat $
- Since:
- 0.1.0
- See Also:
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.value.TimeValue"
-
Field Summary
Fields inherited from class org.tquadrat.foundation.value.api.ValueBase
DEFAULT_VALIDATORFields inherited from interface org.tquadrat.foundation.value.api.DimensionedValue
MATH_CONTEXT -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newTimeValueinstance.TimeValue(Time dimension, BigDecimal value) Creates a newTimeValueinstance.Creates a newTimeValueinstance.Creates a newTimeValueinstance.Creates a newTimeValueinstance. -
Method Summary
Modifier and TypeMethodDescriptionfinal DurationReturns this instance ofTimeValueas an instance ofDuration.final TimeValueclone()Creates a new copy of this value.private static final BigDecimalconvertDurationToNanos(Duration duration) Converts the given instance ofDurationto nanoseconds.final voidprivate static final DurationtranslatePeriodToDuration(Period period) Methods inherited from class org.tquadrat.foundation.value.api.ValueBase
baseValue, copy, copy, equals, getUnit, hashCode, setUnit, toString
-
Constructor Details
-
TimeValue
Creates a newTimeValueinstance.- Parameters:
dimension- The dimension.value- The value.
-
TimeValue
Creates a newTimeValueinstance.- Parameters:
dimension- The dimension.value- The value; it must be possible to parse the given String into aBigDecimal.- Throws:
NumberFormatException- The provided value cannot be converted into aBigDecimal.
-
TimeValue
Creates a newTimeValueinstance.- Type Parameters:
N- The type ofvalue.- Parameters:
dimension- The dimension.value- The value.
-
TimeValue
Creates a newTimeValueinstance.- Parameters:
dimension- The dimension.value- The value.
-
TimeValue
Creates a newTimeValueinstance.- Parameters:
dimension- The dimension.value- The value.
-
-
Method Details
-
asDuration
Returns this instance ofTimeValueas an instance ofDuration.- Returns:
- The duration that corresponds to this time value.
-
clone
Creates a new copy of this value. -
convertDurationToNanos
Converts the given instance ofDurationto nanoseconds.- Parameters:
duration- The duration.- Returns:
- The nanoseconds value,
-
formatTo
The precision is applied to the numerical part only. The width includes the unit symbol, too.
- See Also:
-
translatePeriodToDuration
- Parameters:
period- The period to translate.- Returns:
- The resulting duration.
-
