public class Duration extends Object implements Serializable
Constructor and Description |
---|
Duration()
Default no-arg constructor
|
Duration(boolean negative,
Calendar calendar)
Constructs Duration from a Calendar.
|
Duration(boolean negative,
int aYears,
int aMonths,
int aDays,
int aHours,
int aMinutes,
double aSeconds) |
Duration(String duration)
Constructs Duration from a String in an xsd:duration format -
PnYnMnDTnHnMnS.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object object)
The equals method compares the time represented by duration object, not
its string representation.
|
Calendar |
getAsCalendar()
Returns duration as a calendar.
|
Calendar |
getAsCalendar(Calendar startTime)
Returns duration as a calendar.
|
int |
getDays() |
int |
getHours() |
int |
getMinutes() |
int |
getMonths() |
double |
getSeconds() |
int |
getYears() |
int |
hashCode() |
boolean |
isNegative() |
void |
parseDate(String date)
This method parses the date portion of a String that represents
xsd:duration - nYnMnD.
|
void |
parseTime(String time)
This method parses the time portion of a String that represents
xsd:duration - nHnMnS.
|
void |
setDays(int days) |
void |
setHours(int hours) |
void |
setMinutes(int minutes) |
void |
setMonths(int months) |
void |
setNegative(boolean negative) |
void |
setSeconds(double seconds)
Sets the seconds.
|
void |
setSeconds(int seconds)
Deprecated.
use
setSeconds(double)
instead |
void |
setYears(int years) |
String |
toString()
This returns the xml representation of an xsd:duration object.
|
public Duration()
public Duration(boolean negative, int aYears, int aMonths, int aDays, int aHours, int aMinutes, double aSeconds)
negative
- aYears
- aMonths
- aDays
- aHours
- aMinutes
- aSeconds
- public Duration(String duration) throws IllegalArgumentException
duration
- StringSchemaException
- if the string doesn't parse correctly.IllegalArgumentException
public Duration(boolean negative, Calendar calendar) throws IllegalArgumentException
calendar
- CalendarIllegalArgumentException
- if the calendar object does not
represent any date nor time.public void parseTime(String time) throws IllegalArgumentException
time
- IllegalArgumentException
- if time does not match patternpublic void parseDate(String date) throws IllegalArgumentException
date
- IllegalArgumentException
- if date does not match patternpublic boolean isNegative()
public int getYears()
public int getMonths()
public int getDays()
public int getHours()
public int getMinutes()
public double getSeconds()
public void setNegative(boolean negative)
negative
- public void setYears(int years)
years
- public void setMonths(int months)
months
- public void setDays(int days)
days
- public void setHours(int hours)
hours
- public void setMinutes(int minutes)
minutes
- public void setSeconds(int seconds)
setSeconds(double)
insteadseconds
- public void setSeconds(double seconds)
seconds
- doublepublic String toString()
public boolean equals(Object object)
public Calendar getAsCalendar()
public Calendar getAsCalendar(Calendar startTime)
startTime
- CalendarCopyright © The Apache Software Foundation. All Rights Reserved.