|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.fikin.pojostate.format.Duration
public class Duration
Duration data type object represented as long value of milliseconds.
The Duration class wraps a value of the primitive type
long in an object. An object of type Duration
contains a single field whose type is long.
created on Jul 19, 2005
| Constructor Summary | |
|---|---|
Duration(long milliseconds)
Constructs a newly allocated Duration object that
represents the specified long argument. |
|
Duration(java.lang.String milliseconds)
Constructs a newly allocated Duration object that
represents the long value indicated by the
String parameter. |
|
| Method Summary | |
|---|---|
int |
compareTo(Duration anotherDuration)
Compares two Duration objects numerically. |
int |
compareTo(java.lang.Object o)
Compares this Duration object to another object. |
int |
getDays()
|
int |
getHours()
|
int |
getMilliseconds()
|
int |
getMinutes()
|
int |
getSeconds()
|
int |
getTotalDays()
|
int |
getTotalHours()
|
long |
getTotalMilliseconds()
|
long |
getTotalMinutes()
|
long |
getTotalSeconds()
|
int |
getWeeks()
|
long |
longValue()
Returns the value of this Duration as a
long value representing milliseconds. |
static long |
parseDuration(java.lang.String milliseconds)
Parses the string argument as a signed decimal long. |
java.lang.String |
toString()
Returns a String object representing this
Duration's value. |
static java.lang.String |
toString(long milliseconds)
Returns a String object representing the specified
long. |
static Duration |
valueOf(java.lang.String milliseconds)
Returns a Duration object holding the value
of the specified String. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Duration(long milliseconds)
Duration object that
represents the specified long argument.
milliseconds - the value to be represented by the
Duration object.
public Duration(java.lang.String milliseconds)
throws java.lang.NumberFormatException
Duration object that
represents the long value indicated by the
String parameter. The string is converted to a
long value in exactly the manner used by the
parseDuration method for radix 10.
milliseconds - is duration in milliseconds to be assigned to
this Duration object.
java.lang.NumberFormatException - if the String does not
contain a parsable long.parseDuration(String)| Method Detail |
|---|
public int getMilliseconds()
public int getSeconds()
public int getMinutes()
public int getHours()
public int getDays()
public int getWeeks()
public int getTotalDays()
public int getTotalHours()
public long getTotalMinutes()
public long getTotalSeconds()
public long getTotalMilliseconds()
public long longValue()
Duration as a
long value representing milliseconds.
public int compareTo(Duration anotherDuration)
Duration objects numerically.
anotherDuration - the Duration to be compared.
0 if this Duration is
equal to the argument Duration; a value less than
0 if this Duration is numerically less
than the argument Duration; and a value greater
than 0 if this Duration is numerically
greater than the argument Duration (signed
comparison).public int compareTo(java.lang.Object o)
Duration object to another object. If
the object is a Duration, this function behaves like
compareTo(Duration). Otherwise, it throws a
ClassCastException (as Duration objects
are comparable only to other Duration objects).
compareTo in interface java.lang.Comparableo - the Object to be compared.
0 if the argument is a
Duration numerically equal to this
Duration; a value less than 0
if the argument is a Duration numerically
greater than this Duration; and a value
greater than 0 if the argument is a
Duration numerically less than this
Duration.
ClassCastException - if the argument is not a
Duration.Comparablepublic java.lang.String toString()
String object representing this
Duration's value. The value is converted to signed
decimal representation and returned as a string, exactly as if
the long value were given as an argument to the
toString(long) method.
toString in class java.lang.Objectpublic static Duration valueOf(java.lang.String milliseconds)
Duration object holding the value
of the specified String. The argument is
interpreted as representing a signed decimal long,
exactly as if the argument were given to the parseDuration(java.lang.String) method. The result is a
Duration object that represents the integer value
specified by the string.
In other words, this method returns a Duration object
equal to the value of:
new Duration(Duration.parseDuration(s))
milliseconds - the string to be parsed.
Duration object holding the value
represented by the string argument.
java.lang.NumberFormatException - If the string cannot be parsed
as a long.public static java.lang.String toString(long milliseconds)
String object representing the specified
long. The argument is converted to signed decimal
representation and returned as a string, exactly as if the
argument and the radix 10 were given as arguments to the
toString(long) method.
milliseconds - is duration in milliseconds to be converted.
public static long parseDuration(java.lang.String milliseconds)
throws java.lang.NumberFormatException
long.
The characters in the string must all be
decimal digits, except that the first character may be an ASCII
minus sign '-' (\u002D') to
indicate a negative value. The resulting long
value is returned, exactly as if the argument and the radix
10 were given as arguments to the
parseDuration(String) method.
Note that neither the character L
('\u004C') nor l
('\u006C') is permitted to appear at the end
of the string as a type indicator, as would be permitted in
Java programming language source code.
milliseconds - is duration in milliseconds
long representing the argument in string.
java.lang.NumberFormatException - if the string does not contain a
parsable long.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||