public final class DayTimeDurationValue extends DurationValue implements java.lang.Comparable<DayTimeDurationValue>
Internally this is held as an integer number of seconds held in a positive long, a positive integer number of microseconds in the range 0 to 999,999,999, and a boolean sign. Some of the constructor and accessor methods cannot handle the full range of values.
months, nanoseconds, negative, secondstypeLabelNaN_MATCH_KEY| Constructor and Description |
|---|
DayTimeDurationValue(int sign,
int days,
int hours,
int minutes,
long seconds,
int microseconds)
Create a dayTimeDuration given the number of days, hours, minutes, and seconds.
|
DayTimeDurationValue(int days,
int hours,
int minutes,
long seconds,
int nanoseconds)
Create a dayTimeDuration given the number of days, hours, minutes, seconds, and nanoseconds.
|
| Modifier and Type | Method and Description |
|---|---|
DurationValue |
add(DurationValue other)
Add two dayTimeDurations
|
int |
compareTo(DayTimeDurationValue other)
Compare the value to another duration value
|
AtomicValue |
copyAsSubType(AtomicType typeLabel)
Create a copy of this atomic value, with a different type label
|
DurationValue |
divide(double n)
Divide duration by a number.
|
BigDecimalValue |
divide(DurationValue other)
Find the ratio between two durations
|
static DayTimeDurationValue |
fromJavaDuration(java.time.Duration duration)
Factory method taking a Java 8
Duration object |
static DayTimeDurationValue |
fromMicroseconds(long microseconds)
Construct a duration value as a number of microseconds.
|
static DayTimeDurationValue |
fromMilliseconds(long milliseconds)
Construct a duration value as a number of milliseconds.
|
static DayTimeDurationValue |
fromNanoseconds(long nanoseconds)
Construct a duration value as a number of nanoseconds.
|
static DayTimeDurationValue |
fromSeconds(java.math.BigDecimal seconds)
Construct a duration value as a number of seconds.
|
long |
getLengthInMicroseconds()
Get the length of duration in microseconds, as a long
|
long |
getLengthInNanoseconds()
Get the length of duration in microseconds, as a long
|
double |
getLengthInSeconds()
Get the length of duration in seconds.
|
java.lang.CharSequence |
getPrimitiveStringValue()
Convert to string
|
BuiltInAtomicType |
getPrimitiveType()
Determine the primitive type of the value.
|
AtomicMatchKey |
getXPathComparable(boolean ordered,
StringCollator collator,
int implicitTimezone)
Get a Comparable value that implements the XPath ordering comparison semantics for this value.
|
static ConversionResult |
makeDayTimeDurationValue(java.lang.CharSequence s)
Factory method: create a duration value from a supplied string, in
ISO 8601 format
[-]PnDTnHnMnS |
DayTimeDurationValue |
multiply(double n)
Multiply duration by a number.
|
DurationValue |
multiply(long factor)
Multiply a duration by an integer
|
DurationValue |
negate()
Negate a duration (same as subtracting from zero, but it preserves the type of the original duration)
|
DurationValue |
subtract(DurationValue other)
Subtract two dayTime-durations
|
java.time.Duration |
toJavaDuration()
Convert this value to a Java 8
Duration object |
badDuration, badDuration, equals, getComponent, getDays, getHours, getMicroseconds, getMinutes, getMonths, getNanoseconds, getSchemaComparable, getSchemaComparable, getSeconds, getTotalMonths, getTotalSeconds, getYears, hashCode, makeDuration, makeDuration, normalizeZeroDuration, signum, simpleIntegerasAtomic, asMapKey, atomize, checkPermittedContents, checkValidInJavascript, effectiveBooleanValue, getCanonicalLexicalRepresentation, getCardinality, getGenre, getItemType, getLength, getStringValue, getStringValueCS, getUType, head, identityHashCode, isIdentical, isIdentical, isNaN, itemAt, iterate, iterator, process, setTypeLabel, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitasAtomicisStreamed, reduce, subsequence, toGroundedValue, toShortStringasIterable, materializemakeRepeatablepublic DayTimeDurationValue(int sign,
int days,
int hours,
int minutes,
long seconds,
int microseconds)
throws java.lang.IllegalArgumentException
Note: for historic reasons this constructor only supports microsecond precision. For nanosecond
precision, use the constructor DayTimeDurationValue(int, int, int, long, int)
sign - positive number for positive durations, negative for negative duratoinsdays - number of dayshours - number of hoursminutes - number of minutesseconds - number of secondsmicroseconds - number of microsecondsjava.lang.IllegalArgumentException - if the value is out of range; specifically, if the total
number of seconds exceeds 2^63; or if any of the values is negativepublic DayTimeDurationValue(int days,
int hours,
int minutes,
long seconds,
int nanoseconds)
throws java.lang.IllegalArgumentException
To construct a positive duration, all the component values should be positive integers (or zero). To construct a negative duration, all the component values should be negative integers (or zero).
days - number of dayshours - number of hoursminutes - number of minutesseconds - number of secondsnanoseconds - number of nanosecondsjava.lang.IllegalArgumentException - if the value is out of range; specifically, if the total
number of seconds exceeds 2^63; or if some values are positive and
others are negativepublic static ConversionResult makeDayTimeDurationValue(java.lang.CharSequence s)
[-]PnDTnHnMnSs - the lexical representation of the xs:dayTimeDuration valueDayTimeDurationValue if the format is correct, or a ValidationFailure if notpublic AtomicValue copyAsSubType(AtomicType typeLabel)
copyAsSubType in class DurationValuetypeLabel - the type label of the new copy. The caller is responsible for checking that
the value actually conforms to this type.public BuiltInAtomicType getPrimitiveType()
getPrimitiveType in class DurationValuepublic java.lang.CharSequence getPrimitiveStringValue()
getPrimitiveStringValue in class DurationValuepublic double getLengthInSeconds()
DurationValue.getTotalSeconds()getLengthInSeconds in class DurationValuepublic long getLengthInMicroseconds()
java.lang.ArithmeticException - if the number of microseconds is too high to be returned as a long.public long getLengthInNanoseconds()
java.lang.ArithmeticException - if the number of nanoseconds is too high to be returned as a long.public static DayTimeDurationValue fromSeconds(java.math.BigDecimal seconds)
seconds - the number of seconds in the duration. May be negativejava.lang.ArithmeticException - if the number of (whole) seconds exceeds 2^63public static DayTimeDurationValue fromMilliseconds(long milliseconds) throws ValidationException
milliseconds - the number of milliseconds in the duration (may be negative)ValidationException - if implementation-defined limits are exceeded, specifically
if the total number of seconds exceeds 2^63.public static DayTimeDurationValue fromMicroseconds(long microseconds) throws java.lang.IllegalArgumentException
microseconds - the number of microseconds in the duration.java.lang.IllegalArgumentExceptionpublic static DayTimeDurationValue fromNanoseconds(long nanoseconds) throws java.lang.IllegalArgumentException
nanoseconds - the number of nanoseconds in the duration.java.lang.IllegalArgumentExceptionpublic static DayTimeDurationValue fromJavaDuration(java.time.Duration duration)
Duration objectduration - a duration as a Java 8 java.time.Durationpublic java.time.Duration toJavaDuration()
Duration objectjava.time.Durationpublic DurationValue multiply(long factor) throws XPathException
multiply in class DurationValuefactor - the number to multiply byXPathExceptionpublic DayTimeDurationValue multiply(double n) throws XPathException
multiply in class DurationValuen - the number to multiply by.XPathException - if the operand is Infinite or NaN, or if the resulting duration
exceeds Saxon limits (2^63 seconds)public DurationValue divide(double n) throws XPathException
divide in class DurationValuen - the number to divide by.XPathException - if the operand is zero or NaN, or if the resulting duration
exceeds Saxon limits (2^63 seconds)public BigDecimalValue divide(DurationValue other) throws XPathException
divide in class DurationValueother - the dividendXPathException - when dividing by zero, or when dividing two durations of different typepublic DurationValue add(DurationValue other) throws XPathException
add in class DurationValueother - the duration to be added to this oneXPathExceptionpublic DurationValue subtract(DurationValue other) throws XPathException
subtract in class DurationValueother - the duration to be subtracted from this oneXPathExceptionpublic DurationValue negate() throws java.lang.IllegalArgumentException
negate in class DurationValuejava.lang.IllegalArgumentException - in the extremely unlikely event that the duration is one that cannot
be negated (because the limit for positive durations is one second
off from the limit for negative durations)public int compareTo(DayTimeDurationValue other)
compareTo in interface java.lang.Comparable<DayTimeDurationValue>other - The other dateTime valuejava.lang.ClassCastException - if the other value is not a DayTimeDurationValuepublic AtomicMatchKey getXPathComparable(boolean ordered, StringCollator collator, int implicitTimezone)
getXPathComparable in class DurationValueordered - true if an ordered comparable is neededcollator - Collation used for string comparisonimplicitTimezone - XPath dynamic contextCopyright (c) 2004-2020 Saxonica Limited. All rights reserved.