Class TimeValue
java.lang.Object
org.tquadrat.foundation.value.api.ValueBase<Time, TimeValue>
org.tquadrat.foundation.value.TimeValue
- 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 ValueBase
DEFAULT_VALIDATORFields inherited from interface DimensionedValue
MATH_CONTEXT -
Constructor Summary
ConstructorsModifierConstructorDescriptionCreates a newTimeValueinstance.TimeValue(Time dimension, BigDecimal value) Creates a newTimeValueinstance.Creates a newTimeValueinstance.Creates a newTimeValueinstance.<N extends Number>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)
-
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
-
TimeValue
-
TimeValue
-
-
Method Details
-
asDuration
Returns this instance ofTimeValueas an instance ofDuration.- Returns:
- The duration that corresponds to this time value.
-
clone
-
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.
-
