- All Implemented Interfaces:
Serializable,Comparable<TimeScale>,Constable
Scales milliseconds into standard human time units and standard human time
units into milliseconds. Also provides formatting for the same.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptiondayshoursmillisecondsminutesseconds -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal longThe number of milliseconds in one TimeUnit. -
Method Summary
Modifier and TypeMethodDescriptionlongasMilliseconds(double unitCount) Gets the number of milliseconds in theunitcountnumber of TimeUnits.displayValue(long milliseconds) Format the number of milliseconds in this TimeScale along with the number of Milliseconds.format(long milliseconds) Format the number of milliseconds into this TimeScale.static TimeScalescaleOf(long milliseconds) Returns the largest TimeScale that will representmillisecondswith at least 1 unit.static Stringsize(int milliseconds) Formats the milliseconds into a TimeScale that best fits the number of milliseconds.unitName()Gets the name of the units for this TimeScale.units(int unitCount) Format the number of units of this TimeScale for output.static TimeScaleReturns the enum constant of this class with the specified name.static TimeScale[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
MILLISECONDS
milliseconds -
SECONDS
seconds -
MINUTES
minutes -
HOURS
hours -
DAYS
days
-
-
Field Details
-
milliseconds
public final long millisecondsThe number of milliseconds in one TimeUnit.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
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
-
displayValue
Format the number of milliseconds in this TimeScale along with the number of Milliseconds. For example "3.5 minutes (210000 milliseconds)". If the Timescale is MILLISECONDS then the parenthetical portion is not displayed.- Parameters:
milliseconds- the number of milliseconds to format.- Returns:
- the String representation of the number and TimeUnit as well as the number of milliseconds.
-
unitName
Gets the name of the units for this TimeScale.- Returns:
- the name of the units.
-
format
Format the number of milliseconds into this TimeScale.- Parameters:
milliseconds- the number of milliseconds.- Returns:
- a formatted string representation.
-
units
Format the number of units of this TimeScale for output.- Parameters:
unitCount- the number of TimeScale units.- Returns:
- the formatted string.
-
asMilliseconds
public long asMilliseconds(double unitCount) Gets the number of milliseconds in theunitcountnumber of TimeUnits.- Parameters:
unitCount- the number of TimeUnits- Returns:
- the number of milliseconds.
-
scaleOf
Returns the largest TimeScale that will representmillisecondswith at least 1 unit.- Parameters:
milliseconds- the number of milliseconds- Returns:
- the TimeScale for the milliseconds.
-
size
Formats the milliseconds into a TimeScale that best fits the number of milliseconds.- Parameters:
milliseconds- the number of milliseconds.- Returns:
- the String representation.
- See Also:
-