|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.pfsw.text.TimeValue
public class TimeValue
Represents a time value and provides parsing of strings and various different getters for various time units.
| Constructor Summary | |
|---|---|
TimeValue(long millisecondsValue)
Initialize the new instance with a milliseconds value. |
|
TimeValue(long value,
TimeUnit unit)
Initialize the new instance with a value and unit. |
|
TimeValue(NaturalNumber value,
TimeUnit unit)
Initialize the new instance with a value and unit. |
|
TimeValue(java.lang.String strValue)
Initialize the new instance with a string that must contain digits, optionally followed by the short name of a unit (@see TimeUnit. |
|
TimeValue(java.lang.String strValue,
TimeUnit defaultUnit)
Initialize the new instance with a string that must contain digits, optionally followed by the short name of a unit (@see TimeUnit. |
|
| Method Summary | |
|---|---|
long |
asHours()
Returns the underlying time in hours. |
long |
asMilliseconds()
|
long |
asMinutes()
|
long |
asSeconds()
|
int |
compareTo(TimeValue other)
|
long |
convertTo(TimeUnit unit)
Returns the value converted to the specified unit. |
static TimeValue |
create(long millisecondsValue)
Creates a new instance with the given milliseconds value. |
static TimeValue |
create(long value,
TimeUnit unit)
Creates a new instance with the given value and time unit. |
static TimeValue |
create(NaturalNumber value,
TimeUnit unit)
Creates a new instance with the given value and time unit. |
static TimeValue |
create(java.lang.String strValue)
Creates a the new instance with a string that must contain digits, optionally followed by the short name of a unit (@see TimeUnit. |
static TimeValue |
create(java.lang.String strValue,
TimeUnit defaultUnit)
Creates a new instance with a string that must contain digits, optionally followed by the short name of a unit (@see TimeUnit. |
boolean |
equals(java.lang.Object obj)
|
protected long |
getMilliseconds()
|
int |
hashCode()
|
protected long |
parseToMilliseconds(java.lang.String strValue,
TimeUnit defaultUnit)
Parse the given string, taking any optional unit string at the end into account. |
protected void |
setMilliseconds(long milliseconds)
|
protected StringPair |
splitDigitsAndUnit(java.lang.String str)
|
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public TimeValue(long millisecondsValue)
public TimeValue(long value,
TimeUnit unit)
public TimeValue(NaturalNumber value,
TimeUnit unit)
public TimeValue(java.lang.String strValue,
TimeUnit defaultUnit)
TimeUnit.
strValue - The string to parse (must not be null).defaultUnit - The unit to use if the string does not contain an explicit short name (must not be null).
java.lang.NumberFormatException - If the string does not contain a valid long value.public TimeValue(java.lang.String strValue)
TimeUnit.
java.lang.NumberFormatException - If the string does not contain a valid long value.| Method Detail |
|---|
public static TimeValue create(long millisecondsValue)
public static TimeValue create(long value,
TimeUnit unit)
public static TimeValue create(NaturalNumber value,
TimeUnit unit)
public static TimeValue create(java.lang.String strValue,
TimeUnit defaultUnit)
TimeUnit.
strValue - The string to parse (must not be null).defaultUnit - The unit to use if the string does not contain an explicit short name (must not be null).
java.lang.NumberFormatException - If the string does not contain a valid long value.public static TimeValue create(java.lang.String strValue)
TimeUnit.
java.lang.NumberFormatException - If the string does not contain a valid long value.public long asMilliseconds()
public long asSeconds()
public long asMinutes()
public long asHours()
public long convertTo(TimeUnit unit)
unit - The unit of the result value (must not be null).public java.lang.String toString()
toString in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int compareTo(TimeValue other)
compareTo in interface java.lang.Comparable<TimeValue>
protected long parseToMilliseconds(java.lang.String strValue,
TimeUnit defaultUnit)
strValue - The string to parsedefaultUnit - The unit to use if the string does not contain an explicit short name.
java.lang.NumberFormatException - If the string does not contain a valid long value or an invalid unit.protected StringPair splitDigitsAndUnit(java.lang.String str)
protected long getMilliseconds()
protected void setMilliseconds(long milliseconds)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||