Package com.complexible.common.timer
Enum Class DurationFormat
- All Implemented Interfaces:
Serializable,Comparable<DurationFormat>,Constable
A simple class to provide various formatting options for durations represented in milliseconds. The durations are displayed in terms of hours, minutes, seconds, and milliseconds.
- Since:
- 2.0
- Version:
- 2.0
- Author:
- Evren Sirin
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionformat(long durationInMilliseconds) Format the given duration in milliseconds according to the style defined by this DurationFormat class.static DurationFormatReturns the enum constant of this class with the specified name.static DurationFormat[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
FULL
Format duration in full format. Example: 0 hour(s) 2 minute(s) 13 second(s) 572 milliseconds(s) -
LONG
Format duration in long format. Example: 00:02:13.572 -
MEDIUM
Format duration in medium format (no milliseconds). Example: 00:02:13 -
SHORT
Format duration in short format (no hours or milliseconds). Example: 00:02
-
-
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
-
format
Format the given duration in milliseconds according to the style defined by this DurationFormat class.- Parameters:
durationInMilliseconds- duration represented in milliseconds- Returns:
- duration formatted as a string
-