Enum Class Time
- All Implemented Interfaces:
Serializable, Comparable<Time>, Constable, Dimension, DimensionWithLinearConversion
@ClassVersion(sourceVersion="$Id: Time.java 1195 2026-04-15 21:33:40Z tquadrat $")
@API(status=STABLE,
since="0.1.0")
public enum Time
extends Enum<Time>
implements DimensionWithLinearConversion
The various instances of time periods …
The instance of Time refers to the respective instances of
TimeUnit
and
ChronoUnit
wherever possible.
- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: Time.java 1195 2026-04-15 21:33:40Z tquadrat $
- Since:
- 0.1.0
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.value.Time"
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classAn implementation ofTemporalUnit, based on the settings for theTimeinstance.Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionA bank month.A bank year.A century.A day.A decade.A fortnight (2 weeks or 14 days).Half a day.An hour.A microsecond.A millisecond.A minute.A month.A nanosecond.A second.A year.A week (7 days).A tropical year, according to SI. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BigDecimalThe factor.private final Optional<TemporalUnit> The time unit as used by thejava.timepackage.private final TimeUnitThe time unit as used by thejava.util.concurrentpackage.private final StringThe unit symbol.Fields inherited from interface DimensionWithLinearConversion
MSG_UnknownUnit -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateTime(BigDecimal factor, String unitSymbol, TimeUnit timeUnit, TemporalUnit temporalUnit) Creates a newTimeinstance. -
Method Summary
Modifier and TypeMethodDescriptionprotected TemporalUnitReturns this instance ofTimeas an instance ofTemporalUnit.final TimebaseUnit()final BigDecimalfactor()static final TimeReturns theTimeinstance for the given unit.static final TimeforUnit(ChronoUnit unit) Returns theTimeinstance for the given instance ofChronoUnit.static final TimeforUnit(TemporalUnit unit) Returns theTimeinstance for the given instance ofTemporalUnit.static final TimeReturns theTimeinstance for the given instance ofTimeUnit.final TemporalUnitReturns the correspondentTemporalUnitfor this instance, as used by thejava.timepackage.final TimeUnitReturns the correspondentTimeUnitfor this instance, as used by thejava.util.concurrentpackage.final Stringstatic TimeReturns the enum constant of this class with the specified name.static Time[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class Enum
clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOfMethods inherited from interface Dimension
equals, getPrecision, name, toString, unitSymbolForPrintingMethods inherited from interface DimensionWithLinearConversion
fromBase, toBase
-
Enum Constant Details
-
NANOSECOND
A nanosecond. -
MICROSECOND
A microsecond. -
MILLISECOND
A millisecond. -
SECOND
-
MINUTE
-
HOUR
-
HALF_DAY
-
DAY
-
WEEK
-
FORTNIGHT
-
BANK_MONTH
A bank month.
This has a fixed length of exact 30 days.
-
MONTH
-
BANK_YEAR
-
YEAR
-
SIMPLE_YEAR
A year.
This is calculated as the average year with 365.2425 days.
- See Also:
-
DECADE
-
CENTURY
-
-
Field Details
-
m_Factor
The factor. -
m_UnitSymbol
The unit symbol. -
m_TemporalUnit
The time unit as used by thejava.timepackage. -
m_TimeUnit
The time unit as used by thejava.util.concurrentpackage.
-
-
Constructor Details
-
Time
Creates a newTimeinstance.- Parameters:
factor- The factor.unitSymbol- The unit symbol.timeUnit- The time unit as for thejava.util.concurrentpackage; may benull.temporalUnit- The time unit as for thejava.timepackage; may benull.
-
-
Method Details
-
values
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
asTemporalUnit
Returns this instance ofTimeas an instance ofTemporalUnit.- Returns:
thisasTemporalUnit.
-
baseUnit
-
factor
- Specified by:
factorin interfaceDimensionWithLinearConversion
-
forUnit
Returns theTimeinstance for the given instance ofChronoUnit.- Parameters:
unit- The unit.- Returns:
- The respective instance.
- Throws:
IllegalArgumentException- The given unit is unknown.
-
forUnit
Returns theTimeinstance for the given instance ofTemporalUnit.- Parameters:
unit- The unit.- Returns:
- The respective instance.
- Throws:
IllegalArgumentException- The given unit is unknown.
-
forUnit
Returns theTimeinstance for the given instance ofTimeUnit.- Parameters:
unit- The unit.- Returns:
- The respective instance.
- Throws:
IllegalArgumentException- The given unit is unknown.
-
forUnit
Returns theTimeinstance for the given unit.- Parameters:
unitSymbol- The unit symbol.- Returns:
- The respective instance.
- Throws:
IllegalArgumentException- The given unit is unknown.
-
getTemporalUnit
Returns the correspondentTemporalUnitfor this instance, as used by thejava.timepackage. Because we define here more units as in that package, the return value may benull.- Returns:
- The corresponding temporal unit instance, or
nullif there is no corresponding time unit.
-
getTimeUnit
Returns the correspondentTimeUnitfor this instance, as used by thejava.util.concurrentpackage. Because we define here more units as in that package, the return value may benull.- Returns:
- The corresponding time unit instance, or
nullif there is no corresponding time unit.
-
unitSymbol
- Specified by:
unitSymbolin interfaceDimension
-
