- java.lang.Object
-
- java.lang.Enum<SimpleUnit>
-
- com.flexganttfx.model.util.SimpleUnit
-
- All Implemented Interfaces:
Serializable
,Comparable<SimpleUnit>
,TemporalUnit
public enum SimpleUnit extends Enum<SimpleUnit> implements TemporalUnit
A custom temporal unit used for showing numbered units (1, 2, 3, ... or 10, 20, 30, ...).
-
-
Enum Constant Summary
Enum Constants Enum Constant Description BILLION
A granularity representing one billion milliseconds.BILLION_HUNDRED
A granularity representing one hundred billion milliseconds.BILLION_TEN
A granularity representing ten billion milliseconds.HUNDRED
A granularity representing one hundred milliseconds.MILLION
A granularity representing one million milliseconds.MILLION_HUNDRED
A granularity representing one hundred million milliseconds.MILLION_TEN
A granularity representing ten million milliseconds.ONE
A granularity representing one millisecond.TEN
A granularity representing ten milliseconds.THOUSAND
A granularity representing one thousand milliseconds.THOUSAND_HUNDRED
A granularity representing one hundred thousand milliseconds.THOUSAND_TEN
A granularity representing ten thousand milliseconds.TRILLION
A granularity representing one trillion milliseconds.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <R extends Temporal>
RaddTo(R temporal, long periodToAdd)
long
between(Temporal t1, Temporal t2)
long
decrement(long time)
Decrements the given number of milliseconds with the milliseconds represented by the enumerator value.Duration
getDuration()
long
getMillis()
Returns the number of milliseconds represented by the granularity.long
increment(long time)
Increments the given number of milliseconds with the milliseconds represented by the enumerator value.boolean
isDateBased()
boolean
isDurationEstimated()
boolean
isSupportedBy(Temporal temporal)
boolean
isTimeBased()
long
truncate(long time)
Truncates the given time point by rounding it down to the nearest multitude of the milliseconds represented by the granularity value.static SimpleUnit
valueOf(String name)
Returns the enum constant of this type with the specified name.static SimpleUnit[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.-
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Methods inherited from interface java.time.temporal.TemporalUnit
toString
-
-
-
-
Enum Constant Detail
-
ONE
public static final SimpleUnit ONE
A granularity representing one millisecond.- Since:
- 1.0
-
TEN
public static final SimpleUnit TEN
A granularity representing ten milliseconds.- Since:
- 1.0
-
HUNDRED
public static final SimpleUnit HUNDRED
A granularity representing one hundred milliseconds.- Since:
- 1.0
-
THOUSAND
public static final SimpleUnit THOUSAND
A granularity representing one thousand milliseconds.- Since:
- 1.0
-
THOUSAND_TEN
public static final SimpleUnit THOUSAND_TEN
A granularity representing ten thousand milliseconds.- Since:
- 1.0
-
THOUSAND_HUNDRED
public static final SimpleUnit THOUSAND_HUNDRED
A granularity representing one hundred thousand milliseconds.- Since:
- 1.0
-
MILLION
public static final SimpleUnit MILLION
A granularity representing one million milliseconds.- Since:
- 1.0
-
MILLION_TEN
public static final SimpleUnit MILLION_TEN
A granularity representing ten million milliseconds.- Since:
- 1.0
-
MILLION_HUNDRED
public static final SimpleUnit MILLION_HUNDRED
A granularity representing one hundred million milliseconds.- Since:
- 1.0
-
BILLION
public static final SimpleUnit BILLION
A granularity representing one billion milliseconds.- Since:
- 1.0
-
BILLION_TEN
public static final SimpleUnit BILLION_TEN
A granularity representing ten billion milliseconds.- Since:
- 1.0
-
BILLION_HUNDRED
public static final SimpleUnit BILLION_HUNDRED
A granularity representing one hundred billion milliseconds.- Since:
- 1.0
-
TRILLION
public static final SimpleUnit TRILLION
A granularity representing one trillion milliseconds.- Since:
- 1.0
-
-
Method Detail
-
values
public static SimpleUnit[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (SimpleUnit c : SimpleUnit.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static SimpleUnit valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type has no constant with the specified nameNullPointerException
- if the argument is null
-
increment
public long increment(long time)
Increments the given number of milliseconds with the milliseconds represented by the enumerator value.- Parameters:
time
- the time to increment- Returns:
- the given time plus the milliseconds represented by the value
- Since:
- 1.0
-
decrement
public long decrement(long time)
Decrements the given number of milliseconds with the milliseconds represented by the enumerator value.- Parameters:
time
- the time to increment- Returns:
- the given time minus the milliseconds represented by the value
- Since:
- 1.0
-
truncate
public long truncate(long time)
Truncates the given time point by rounding it down to the nearest multitude of the milliseconds represented by the granularity value. Example: the granularityTHOUSAND
would adjust the time point 4366 to 4000.- Parameters:
time
- the time that needs adjustment- Returns:
- a number of milliseconds that is a multitude of the number of milliseconds represented by the enumerator value and that is still smaller than the given time
- Since:
- 1.0
-
getMillis
public long getMillis()
Returns the number of milliseconds represented by the granularity.- Returns:
- number of milliseconds represented by the granularity
- Since:
- 1.0
-
addTo
public <R extends Temporal> R addTo(R temporal, long periodToAdd)
- Specified by:
addTo
in interfaceTemporalUnit
-
between
public long between(Temporal t1, Temporal t2)
- Specified by:
between
in interfaceTemporalUnit
-
getDuration
public Duration getDuration()
- Specified by:
getDuration
in interfaceTemporalUnit
-
isDateBased
public boolean isDateBased()
- Specified by:
isDateBased
in interfaceTemporalUnit
-
isDurationEstimated
public boolean isDurationEstimated()
- Specified by:
isDurationEstimated
in interfaceTemporalUnit
-
isSupportedBy
public boolean isSupportedBy(Temporal temporal)
- Specified by:
isSupportedBy
in interfaceTemporalUnit
-
isTimeBased
public boolean isTimeBased()
- Specified by:
isTimeBased
in interfaceTemporalUnit
-
-