public class Duration extends java.lang.Object implements XdmDuration
Constructor and Description |
---|
Duration()
Construct a duration object, initialized to zero length.
|
Duration(boolean negative,
int years,
int months,
int days,
int hours,
int minutes,
java.math.BigDecimal seconds)
Construct a duration object by specifying the individual values.
|
Duration(java.lang.String duration)
Construct a duration object initialized from the given string in the format of a serialized
xs:duration item.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object otherObj)
Compares this
XdmDuration object to the specified object. |
int |
getDays() |
int |
getHours() |
int |
getMinutes() |
int |
getMonths() |
java.math.BigDecimal |
getSeconds() |
long |
getWholeSeconds() |
int |
getYears() |
int |
hashCode() |
boolean |
isNegative() |
boolean |
isPositive() |
void |
setDays(int days)
Sets the days value of this duration.
|
void |
setHours(int hours)
Sets the hours value of this duration.
|
void |
setMinutes(int minutes)
Sets the minutes value of this duration.
|
void |
setMonths(int months)
Sets the months value of this duration.
|
void |
setSign(boolean negative)
Sets the sign of this duration, either positive or negative.
|
void |
setWholeSeconds(long seconds)
Sets the seconds value of this duration.
|
void |
setYears(int years)
Sets the years value of this duration.
|
java.lang.String |
toString()
Formats this duration object as a String in the format prescribed in the W3C description of
XML datatypes for a duration.
|
public Duration()
public Duration(java.lang.String duration)
duration
- An xs:duration value as defined by Throws:
java.lang.IllegalArgumentException
- If the given string is not a valid duration value.public Duration(boolean negative, int years, int months, int days, int hours, int minutes, java.math.BigDecimal seconds)
negative
- Pass true if the duration should be neagtive, otherwise false.years
- The number of years.months
- The number of months.days
- The number of days.hours
- The number of hours.minutes
- The number of minutes.seconds
- The (possibly fractional) number of seconds. Note that this is specified by a
BigDecimal
object. If null, a value of zero is assumed.public boolean isPositive()
isPositive
in interface XdmDuration
public boolean isNegative()
isNegative
in interface XdmDuration
public int getYears()
getYears
in interface XdmDuration
public int getMonths()
getMonths
in interface XdmDuration
public int getDays()
getDays
in interface XdmDuration
public int getHours()
getHours
in interface XdmDuration
public int getMinutes()
getMinutes
in interface XdmDuration
public long getWholeSeconds()
getWholeSeconds
in interface XdmDuration
public java.math.BigDecimal getSeconds()
getSeconds
in interface XdmDuration
public void setSign(boolean negative)
negative
- If true, the duration is considered negative, otherwise it's positive.public void setYears(int years)
years
- the integer years value.public void setMonths(int months)
months
- the integer months value.public void setDays(int days)
days
- the integer days value.public void setHours(int hours)
hours
- the integer hours value.public void setMinutes(int minutes)
minutes
- the integer minutes value.public void setWholeSeconds(long seconds)
seconds
- the integer seconds value.public boolean equals(java.lang.Object otherObj)
XdmDuration
object to the specified object. The result is true if and
only if the argument is not null and the sign, year, month, day, hours, minutes, seconds and
subseconds values have the same value as this object.equals
in class java.lang.Object
otherObj
- the Duration object to comparepublic int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
Copyright © 2024 MarkLogic Corporation
Complete online documentation for MarkLogic Server, XQuery and related components may be found at developer.marklogic.com