- 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_VALIDATOR
Fields inherited from interface org.tquadrat.foundation.value.api.DimensionedValue
MATH_CONTEXT
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a newTimeValue
instance.TimeValue
(Time dimension, BigDecimal value) Creates a newTimeValue
instance.Creates a newTimeValue
instance.Creates a newTimeValue
instance.Creates a newTimeValue
instance. -
Method Summary
Modifier and TypeMethodDescriptionfinal Duration
Returns this instance ofTimeValue
as an instance ofDuration
.final TimeValue
clone()
Creates a new copy of this value.private static final BigDecimal
convertDurationToNanos
(Duration duration) Converts the given instance ofDuration
to nanoseconds.final void
private static final Duration
translatePeriodToDuration
(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 newTimeValue
instance.- Parameters:
dimension
- The dimension.value
- The value.
-
TimeValue
Creates a newTimeValue
instance.- 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 newTimeValue
instance.- Type Parameters:
N
- The type ofvalue
.- Parameters:
dimension
- The dimension.value
- The value.
-
TimeValue
Creates a newTimeValue
instance.- Parameters:
dimension
- The dimension.value
- The value.
-
TimeValue
Creates a newTimeValue
instance.- Parameters:
dimension
- The dimension.value
- The value.
-
-
Method Details
-
asDuration
Returns this instance ofTimeValue
as 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 ofDuration
to 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.
-