java.io.Serializable
public class Duration
extends java.lang.Object
implements java.io.Serializable
This representation does not support the decimal fraction for the lowest order item.
The order relation provided by this implementation does not follow the guidelines of XML Schema Specification that defines only a partial order.
For more information see X3C XML Schema Specification.
Constructor | Description |
---|---|
Duration() |
default constructor.
|
Duration(long l) |
This constructor fills in the duration fields according to the value of
the long by calling setValue.
|
Duration(java.lang.String duration) |
Constructs a duration from a string.
|
Modifier and Type | Method | Description |
---|---|---|
boolean |
equal(Duration duration) |
Returns true if the instance of TimeDuration has the same fields
of the parameter
|
boolean |
equals(java.lang.Object object) |
Override the java.lang.equals method
|
short |
getDay() |
|
short |
getHour() |
|
long |
getMilli() |
|
short |
getMinute() |
|
short |
getMonth() |
|
short |
getSeconds() |
|
short |
getYear() |
|
int |
hashCode() |
Overrides the java.lang.Object#hashcode method.
|
boolean |
isGreater(Duration duration) |
Returns true if the present instance of TimeDuration is greater than the
parameter
|
boolean |
isNegative() |
|
static java.lang.Object |
parse(java.lang.String str) |
parse a String and convert it into a java.lang.Object
|
static Duration |
parseDuration(java.lang.String str) |
Parse the given string and return a time duration
which represents this string.
|
void |
setDay(short day) |
|
void |
setHour(short hour) |
|
void |
setMilli(long milli) |
|
void |
setMinute(short minute) |
|
void |
setMonth(short month) |
|
void |
setNegative() |
|
void |
setSeconds(short second) |
|
void |
setValue(short year,
short month,
short day,
short hour,
short minute,
short second,
long millisecond) |
Fill in the fields of the duration with the given values
|
void |
setYear(short year) |
|
long |
toLong() |
Convert a duration into a long
This long represents the duration in milliseconds.
|
java.lang.String |
toString() |
Convert a duration into a String conforming to ISO8601 and XML Schema specs
|
public Duration()
public Duration(java.lang.String duration) throws java.text.ParseException
duration
- the string representation of the duration to createjava.text.ParseException
- thrown when the string is not a valid durationpublic Duration(long l)
l
- the long value of the DurationsetValue(short, short, short, short, short, short, long)
public void setYear(short year)
public void setMonth(short month)
public void setDay(short day)
public void setHour(short hour)
public void setMinute(short minute)
public void setSeconds(short second)
public void setMilli(long milli)
public void setNegative()
public void setValue(short year, short month, short day, short hour, short minute, short second, long millisecond)
year
- the year valuemonth
- the month valueday
- the day valuehour
- the hour valueminute
- the minute valuesecond
- the second valuemillisecond
- the second valuepublic short getYear()
public short getMonth()
public short getDay()
public short getHour()
public short getMinute()
public short getSeconds()
public long getMilli()
public boolean isNegative()
public long toLong()
Convert a duration into a long This long represents the duration in milliseconds.
public java.lang.String toString()
toString
in class java.lang.Object
public static java.lang.Object parse(java.lang.String str) throws java.text.ParseException
str
- the string to parsejava.text.ParseException
- a parse exception is thrown if the string to parse
does not follow the rigth format (see the description
of this class)public static Duration parseDuration(java.lang.String str) throws java.text.ParseException
Parse the given string and return a time duration which represents this string.
str
- the string to parsejava.text.ParseException
- thrown when the string is not validpublic int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
equal(org.exolab.castor.types.Duration)
public boolean equal(Duration duration)
duration
- the time duration to comparepublic boolean isGreater(Duration duration)
Note This definition does not follow the XML SCHEMA RECOMMENDATION 05022001 the following total order relation is used : givent t1,t2 timeDuration types t1>t2 iff t1.toLong()>t2.toLong()
duration
- the time duration to compare with the present instanceIntalio Inc. (C) 1999-2008. All rights reserved http://www.intalio.com