public class TimeUnits extends java.lang.Object implements TimeConstants
Modifier and Type | Field and Description |
---|---|
static TimeUnits |
DAY
Day
|
static TimeUnits |
HOUR
Hour
|
static TimeUnits |
MILLISECOND
Millisecond
|
static TimeUnits |
MINUTE
Minute
|
static TimeUnits |
SECOND
Second
|
static TimeUnits[] |
TIME_UNITS
Time units array
|
HOURS_PER_DAY, MINUTES_PER_DAY, MINUTES_PER_HOUR, MS_PER_DAY, MS_PER_HOUR, MS_PER_MINUTE, MS_PER_SECOND, SECONDS_PER_DAY, SECONDS_PER_MINUTE
Modifier | Constructor and Description |
---|---|
|
TimeUnits(java.lang.String unitsText)
Find the time units for the specified units text.
|
protected |
TimeUnits(java.lang.String text,
long msPerUnit)
Create the time units.
|
Modifier and Type | Method and Description |
---|---|
static long |
getMilliseconds(java.lang.String s,
TimeUnits timeUnits)
Get the number of milliseconds represented by the text and may include text
for the time units.
|
long |
getMsPerUnit()
Get the number of milliseconds per unit.
|
static java.lang.String |
getTextValueWithTimeUnits(java.lang.String s,
TimeUnits defaultValue,
long minimumValue)
Gets the text value with time units.
|
java.lang.String |
getTextWithValue(long value)
Get the text for the value and time units.
|
protected static java.lang.String |
getTextWithValue(long value,
java.lang.String unitsText)
Get the text for the value and time units text.
|
protected static java.lang.String |
getTextWithValue(long value,
TimeUnits timeUnits)
Get the text for the value and time units text.
|
java.lang.String |
getTextWithValue(java.lang.String valueText)
Get the text for the value and time units.
|
protected static java.lang.String |
getTextWithValue(java.lang.String valueText,
java.lang.String unitsText)
Get the text for the value and time units text.
|
protected static TimeUnits |
parseTimeUnits(java.lang.String unitsText,
TimeUnits defaultValue)
Parse the units text.
|
java.lang.String |
toString()
The singular text for the time units.
|
java.lang.String |
toString(boolean pluralFlag)
The text for the time units.
|
java.lang.String |
toString(long value)
The text for the time units.
|
static TimeUnits |
valueOf(java.lang.String s)
Gets the time units for the specified text.
|
static TimeUnits |
valueOf(java.lang.String s,
TimeUnits defaultValue)
Gets the time units for the specified text.
|
public static final TimeUnits MILLISECOND
public static final TimeUnits SECOND
public static final TimeUnits MINUTE
public static final TimeUnits HOUR
public static final TimeUnits DAY
public static final TimeUnits[] TIME_UNITS
public TimeUnits(java.lang.String unitsText)
unitsText
- the units text.java.lang.IllegalArgumentException
- if the time unites could not be found.protected TimeUnits(java.lang.String text, long msPerUnit)
text
- the units text (singular.)msPerUnit
- the number of milliseconds per unit.public long getMsPerUnit()
public java.lang.String getTextWithValue(long value)
value
- the number of time units.public java.lang.String getTextWithValue(java.lang.String valueText)
valueText
- the text for the number of time units.public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(boolean pluralFlag)
pluralFlag
- true for plural, false for singular.public java.lang.String toString(long value)
value
- the number of time units.public static long getMilliseconds(java.lang.String s, TimeUnits timeUnits)
s
- the text.timeUnits
- the time units to use if not specified in the text.public static java.lang.String getTextValueWithTimeUnits(java.lang.String s, TimeUnits defaultValue, long minimumValue)
s
- the text which may include text for the time units.defaultValue
- the time units to add if not already specified.minimumValue
- the minimum value.protected static java.lang.String getTextWithValue(long value, java.lang.String unitsText)
value
- the number of time units.unitsText
- the time units text.protected static java.lang.String getTextWithValue(long value, TimeUnits timeUnits)
value
- the number of time units.unitsText
- the time units text.protected static java.lang.String getTextWithValue(java.lang.String valueText, java.lang.String unitsText)
valueText
- the text for the number of time units.unitsText
- the time units text.protected static TimeUnits parseTimeUnits(java.lang.String unitsText, TimeUnits defaultValue)
unitsText
- the units text.defaultValue
- the default time units.public static TimeUnits valueOf(java.lang.String s)
s
- the text or null if none.public static TimeUnits valueOf(java.lang.String s, TimeUnits defaultValue)
s
- the text or null if none.defaultValue
- the default value if no time units found.