net.sf.saxon.value

Class SecondsDurationValue

public final class SecondsDurationValue extends DurationValue implements Comparable

A value of type xsd:dayTimeDuration
Constructor Summary
SecondsDurationValue(CharSequence s)
Constructor: create a duration value from a supplied string, in ISO 8601 format [-]PnDTnHnMnS
SecondsDurationValue(int sign, int days, int hours, int minutes, int seconds, int microseconds)
Create a dayTimeDuration given the number of days, hours, minutes, and seconds
Method Summary
DurationValueadd(DurationValue other, XPathContext context)
Add two dayTimeDurations
intcompareTo(Object other)
Compare the value to another duration value
ObjectconvertToJava(Class target, XPathContext context)
Convert to Java object (for passing to external functions)
DecimalValuedivide(DurationValue other, XPathContext context)
Find the ratio between two durations
static SecondsDurationValuefromMicroseconds(long microseconds)
Construct a duration value as a number of microseconds.
static SecondsDurationValuefromMilliseconds(long milliseconds)
Construct a duration value as a number of milliseconds.
static SecondsDurationValuefromSeconds(BigDecimal seconds)
Construct a duration value as a number of seconds.
ItemTypegetItemType(TypeHierarchy th)
Determine the data type of the exprssion
longgetLengthInMicroseconds()
Get length of duration in microseconds, as a long
longgetLengthInMilliseconds()
Get length of duration in milliseconds, as a long
doublegetLengthInSeconds()
Get length of duration in seconds
CharSequencegetStringValueCS()
Convert to string
DurationValuemultiply(double n, XPathContext context)
Multiply duration by a number.
voidnormalize()
Normalize the value, for example 90M becomes 1H30M
DurationValuesubtract(DurationValue other, XPathContext context)
Subtract two dayTime-durations

Constructor Detail

SecondsDurationValue

public SecondsDurationValue(CharSequence s)
Constructor: create a duration value from a supplied string, in ISO 8601 format [-]PnDTnHnMnS

SecondsDurationValue

public SecondsDurationValue(int sign, int days, int hours, int minutes, int seconds, int microseconds)
Create a dayTimeDuration given the number of days, hours, minutes, and seconds

Method Detail

add

public DurationValue add(DurationValue other, XPathContext context)
Add two dayTimeDurations

compareTo

public int compareTo(Object other)
Compare the value to another duration value

Parameters: other The other dateTime value

Returns: negative value if this one is the earler, 0 if they are chronologically equal, positive value if this one is the later. For this purpose, dateTime values with an unknown timezone are considered to be UTC values (the Comparable interface requires a total ordering).

Throws: ClassCastException if the other value is not a DateTimeValue (the parameter is declared as Object to satisfy the Comparable interface)

convertToJava

public Object convertToJava(Class target, XPathContext context)
Convert to Java object (for passing to external functions)

divide

public DecimalValue divide(DurationValue other, XPathContext context)
Find the ratio between two durations

Parameters: other the dividend

Returns: the ratio, as a decimal

Throws: XPathException

fromMicroseconds

public static SecondsDurationValue fromMicroseconds(long microseconds)
Construct a duration value as a number of microseconds.

fromMilliseconds

public static SecondsDurationValue fromMilliseconds(long milliseconds)
Construct a duration value as a number of milliseconds.

fromSeconds

public static SecondsDurationValue fromSeconds(BigDecimal seconds)
Construct a duration value as a number of seconds.

getItemType

public ItemType getItemType(TypeHierarchy th)
Determine the data type of the exprssion

Parameters: th

Returns: Type.DAY_TIME_DURATION,

getLengthInMicroseconds

public long getLengthInMicroseconds()
Get length of duration in microseconds, as a long

getLengthInMilliseconds

public long getLengthInMilliseconds()
Get length of duration in milliseconds, as a long

getLengthInSeconds

public double getLengthInSeconds()
Get length of duration in seconds

getStringValueCS

public CharSequence getStringValueCS()
Convert to string

Returns: ISO 8601 representation.

multiply

public DurationValue multiply(double n, XPathContext context)
Multiply duration by a number. This is also used when dividing a duration by a number.

normalize

public void normalize()
Normalize the value, for example 90M becomes 1H30M

subtract

public DurationValue subtract(DurationValue other, XPathContext context)
Subtract two dayTime-durations