Class DateTimeValue
- All Implemented Interfaces:
Comparable<XPathComparable>,Iterable<AtomicValue>,TemporalAccessor,AtomicMatchKey,XPathComparable,AtomicSequence,GroundedValue,IdentityComparable,Item,Sequence,ConversionResult
xs:dateTime. This contains integer fields year, month, day, hour, minute,
second, and nanosecond. All these fields except year must be non-negative. In the internal
representation, the sequence of years runs -2, -1, 0, +1, +2: that is, the year before year 1
is year 0.
The value also contains a boolean flag hasNoYearZero. When this flag is set, accessor
methods that expose the year value subtract one if it is non-positive: that is, year 0 is displayed
as -1, year -1 as -2, and so on. Constructor methods, unless otherwise specified, do not set this
flag.
From Saxon 9.9, this class implements the Java 8 interface TemporalAccessor which enables
it to interoperate with Java 8 temporal classes such as Instant and ZonedDateTime.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDateTimeComparable is an object that implements the XML Schema rules for comparing date/time values -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DateTimeValueFixed date/time used by Java (and Unix) as the origin of the universe: 1970-01-01T00:00:00ZFields inherited from class net.sf.saxon.value.CalendarValue
MISSING_TIMEZONE, NO_TIMEZONE, SIXTY, tzMinutesFields inherited from class net.sf.saxon.value.AtomicValue
metadata -
Constructor Summary
ConstructorsConstructorDescriptionDateTimeValue(int year, int month, int day, int hour, int minute, BigDecimal seconds, int tzMinutes) Create a DateTimeValue from its components, defaulting the type annotation to xs:dateTimeStamp if there is a timezone, or xs:dateTime otherwiseDateTimeValue(int year, int month, int day, int hour, int minute, BigDecimal seconds, int tzMinutes, AtomicMetadata typeLabel) Create a DateTimeValue from its components -
Method Summary
Modifier and TypeMethodDescriptionadd(DurationValue duration) Add a duration to a dateTimeadjustTimezone(int timezone) Return a new dateTime with the same normalized value, but in a different timezone.adjustToUTC(int implicitTimezone) Normalize the date and time to be in timezone Z.voidCheck that the value can be handled in SaxonJSintContext-free comparison of two DateTimeValue values.intcompareTo(CalendarValue other, int implicitTimezone) Compare the value to another dateTime value, following the XPath comparison semanticsstatic intcomputeHashCode(int year, int month, int day, int hour, int minute, BigDecimal second, int tzMinutes) booleanContext-free comparison of two dateTime valuesstatic TwineBuilderformatSeconds(BigDecimal seconds, TwineBuilder tb) Format a decimal seconds valuestatic DateTimeValuefromCalendar(Calendar calendar, boolean tzSpecified) Constructor: create a dateTime value given a Java calendar object.static DateTimeValuefromJavaDate(Date suppliedDate) Factory method: create a dateTime value given a Java Date object.static DateTimeValuefromJavaInstant(long seconds, int nano) Factory method: create a dateTime value given the components of a Java Instant.static DateTimeValuefromJavaInstant(Instant instant) Factory method: create a dateTime value given a JavaInstant.static DateTimeValuefromJavaTime(long time) Factory method: create a dateTime value given a Java time, expressed in milliseconds since 1970.static DateTimeValuefromJulianInstant(BigDecimal instant, int tzMinutes) Get the DateTimeValue corresponding to a given Julian instantstatic DateTimeValuefromLocalDateTime(LocalDateTime localDateTime) Factory method: create a dateTime value given a JavaLocalDateTime.static DateTimeValuefromOffsetDateTime(OffsetDateTime offsetDateTime) Factory method: create a dateTime value given a JavaOffsetDateTime.static DateTimeValuefromZonedDateTime(ZonedDateTime zonedDateTime) Factory method: create a dateTime value given a JavaZonedDateTime.Get a Java Calendar object representing the value of this DateTime.Get the canonical lexical representation as defined in XML Schema.getComponent(AccessorFn.Component component) Get a component of the value.static DateTimeValuegetCurrentDateTime(XPathContext context) Get the dateTime value representing the nominal date/time of this transformation run.intgetDay()Get the day component, 1-31intgetHour()Get the hour component, 0-23longgetLong(TemporalField field) Gets the value of the specified field as along.intGet the minute component, 0-59intgetMonth()Get the month component, 1-12Convert to stringDetermine the primitive type of the value.Get the second component, 0-59getXPathComparable(StringCollator collator, int implicitTimezone, int specVersion) Get an object value that implements the XPath equality and ordering comparison semantics for this value.intgetYear()Get the year component, in its internal form (which allows a year zero)inthashCode()Hash code for context-free comparison of date time values.booleanisSupported(TemporalField field) static ConversionResultmakeDateTimeValue(int year, int month, int day, int hour, int minute, BigDecimal seconds) static ConversionResultmakeDateTimeValue(int year, int month, int day, int hour, int minute, BigDecimal seconds, int tzMinutes) Creates an instance of DateTimeValue.static ConversionResultmakeDateTimeValue(UnicodeString s, ConversionRules rules) Factory method: create a dateTime value from a supplied string, in ISO 8601 format.static DateTimeValuemakeDateTimeValue(DateValue date, TimeValue time) Factory method: create a dateTime value given a date and a time.static BigDecimalmakeSeconds(int wholeSeconds, int nanoSeconds) Make a decimal number of seconds from the integer number of whole seconds and the integer number of nanosecondsstatic DateTimeValuenow()Get the dateTime value representing the moment of invocation of this method, in the default timezone set for the platform on which the application is running.static DateTimeValueFactory method: create a dateTime value from a supplied string, in ISO 8601 format, allowing a year value of 0 to represent the year before year 1 (that is, following the XSD 1.1 rules).longGenerate a value from the current date and time that can be used to seed a random number generatorstatic int[]splitSeconds(BigDecimal seconds) Split a decimal number of seconds into the number of whole seconds and the number of nanosecondssubtract(CalendarValue other, XPathContext context) Determine the difference between two points in time, as a durationConvert the value to an xs:dateTime, retaining all the components that are actually present, and substituting conventional values for components that are missing.Extract the Date partGet a Java 8Instantcorresponding to this date and time.Get the Julian instant: a decimal value whose integer part is the Julian day number multiplied by the number of seconds per day, and whose fractional part is the fraction of the second.Get a Java 8LocalDateTimecorresponding to this date and time.Get a Java 8OffsetDateTimecorresponding to this date and time.Extract the Time partGet a Java 8ZonedDateTimecorresponding to this date and time.withMetadata(AtomicMetadata metadata) Make a copy of this date, time, or dateTime value, but with a new type labelMethods inherited from class net.sf.saxon.value.CalendarValue
adjustTimezone, appendString, appendTimezone, appendTimezone, appendTwoDigits, asMapKey, getTimezoneInMinutes, getXMLGregorianCalendar, getXPathMatchKey, hasTimezone, identityHashCode, isIdentical, makeCalendarValue, removeTimezoneMethods inherited from class net.sf.saxon.value.AtomicValue
asAtomic, atomize, checkPermittedContents, effectiveBooleanValue, getCardinality, getGenre, getItemType, getLabel, getLength, getUnicodeStringValue, getUType, head, isIdentical, isNaN, isUntypedAtomic, itemAt, iterate, iterator, show, toShortString, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.sf.saxon.expr.sort.AtomicMatchKey
asAtomic, longHashCodeMethods inherited from interface net.sf.saxon.om.GroundedValue
asIterable, concatenate, containsNode, materializeMethods inherited from interface net.sf.saxon.om.Item
getStringValue, isStreamed, reduce, subsequenceMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface net.sf.saxon.om.Sequence
makeRepeatableMethods inherited from interface java.time.temporal.TemporalAccessor
get, query, range
-
Field Details
-
EPOCH
Fixed date/time used by Java (and Unix) as the origin of the universe: 1970-01-01T00:00:00Z
-
-
Constructor Details
-
DateTimeValue
public DateTimeValue(int year, int month, int day, int hour, int minute, BigDecimal seconds, int tzMinutes, AtomicMetadata typeLabel) Create a DateTimeValue from its components- Parameters:
year- the year; allows year zeromonth- the month (1 to 12)day- the day (1 to 31)hour- the hour (0 to 23)minute- the minute (0 to 59)seconds- the second ( to 59.999999...)tzMinutes- the timezone offset in minutes, orCalendarValue.NO_TIMEZONEif absenttypeLabel- the type annotation
-
DateTimeValue
public DateTimeValue(int year, int month, int day, int hour, int minute, BigDecimal seconds, int tzMinutes) Create a DateTimeValue from its components, defaulting the type annotation to xs:dateTimeStamp if there is a timezone, or xs:dateTime otherwise- Parameters:
year- the year; allows year zeromonth- the month (1 to 12)day- the day (1 to 31)hour- the hour (0 to 23)minute- the minute (0 to 59)seconds- the second ( to 59.999999...)tzMinutes- the timezone offset in minutes, orCalendarValue.NO_TIMEZONEif absent
-
-
Method Details
-
getCurrentDateTime
Get the dateTime value representing the nominal date/time of this transformation run. Two calls within the same query or transformation will always return the same answer.- Parameters:
context- the XPath dynamic context. May be null, in which case the current date and time are taken directly from the system clock- Returns:
- the current xs:dateTime
-
now
Get the dateTime value representing the moment of invocation of this method, in the default timezone set for the platform on which the application is running.- Returns:
- the current dateTime, in the local timezone for the platform.
-
fromCalendar
Constructor: create a dateTime value given a Java calendar object. The#hasNoYearZeroflag is set totrue.- Parameters:
calendar- holds the date and timetzSpecified- indicates whether the timezone is specified
-
fromJavaDate
Factory method: create a dateTime value given a Java Date object. The returned dateTime value will always have a timezone, which will always be UTC.- Parameters:
suppliedDate- holds the date and time- Returns:
- the corresponding xs:dateTime value
- Throws:
XPathException- if a dynamic error occurs
-
fromJavaTime
Factory method: create a dateTime value given a Java time, expressed in milliseconds since 1970. The returned dateTime value will always have a timezone, which will always be UTC.- Parameters:
time- the time in milliseconds since the epoch- Returns:
- the corresponding xs:dateTime value
- Throws:
XPathException- if a dynamic error occurs
-
fromJavaInstant
Factory method: create a dateTime value given the components of a Java Instant. The java.time.Instant class is new in JDK 8, and this method was introduced under older JDKs, so this method takes two arguments, the seconds and nano-seconds values, which can be obtained from a Java Instant using the methods getEpochSecond() and getNano() respectively- Parameters:
seconds- the time in seconds since the epochnano- the additional nanoseconds- Returns:
- the corresponding xs:dateTime value, which will have timezone Z (UTC)
- Throws:
XPathException- if a dynamic error occurs (typically due to overflow)
-
fromJavaInstant
Factory method: create a dateTime value given a JavaInstant. Thejava.time.Instantclass is new in JDK 8.- Parameters:
instant- the point in time- Returns:
- the corresponding xs:dateTime value, which will have timezone Z (UTC)
- Since:
- 9.9
-
fromZonedDateTime
Factory method: create a dateTime value given a JavaZonedDateTime. Thejava.time.ZonedDateTimeclass is new in JDK 8.- Parameters:
zonedDateTime- the supplied zonedDateTime value- Returns:
- the corresponding xs:dateTime value, which will have the same timezone offset as the supplied ZonedDateTime;
the actual (civil) timezone information is lost. The returned value will be an instance of the built-in
subtype
xs:dateTimeStamp - Since:
- 9.9. Changed in 10.0 to retain nanosecond precision.
-
fromOffsetDateTime
Factory method: create a dateTime value given a JavaOffsetDateTime. Thejava.time.OffsetDateTimeclass is new in JDK 8.- Parameters:
offsetDateTime- the supplied zonedDateTime value- Returns:
- the corresponding xs:dateTime value, which will have the same timezone offset as the supplied OffsetDateTime.
The returned value will be an instance of the built-in subtype
xs:dateTimeStamp - Since:
- 10.0.
-
fromLocalDateTime
Factory method: create a dateTime value given a JavaLocalDateTime. Thejava.time.LocalDateTimeclass is new in JDK 8.- Parameters:
localDateTime- the supplied localDateTime value- Returns:
- the corresponding xs:dateTime value, which will have no timezone.
- Since:
- 9.9. Changed in 10.0 to retain nanosecond precision.
-
makeSeconds
Make a decimal number of seconds from the integer number of whole seconds and the integer number of nanoseconds- Parameters:
wholeSeconds- the number of whole secondsnanoSeconds- the number of nanoseconds- Returns:
- the decimal number of seconds
-
splitSeconds
Split a decimal number of seconds into the number of whole seconds and the number of nanoseconds- Parameters:
seconds- the decimal number of second- Returns:
- an array of two integers containing first, the number of seconds, and second, the number of nanoseconds
-
formatSeconds
Format a decimal seconds value -
makeDateTimeValue
Factory method: create a dateTime value given a date and a time.- Parameters:
date- the datetime- the time- Returns:
- the dateTime with the given components. If either component is null, returns null. The returned
DateTimeValuewill have the#hasNoYearZeroproperty if and only if the supplied date has this property. - Throws:
XPathException- if the timezones are both present and inconsistent
-
makeDateTimeValue
Factory method: create a dateTime value from a supplied string, in ISO 8601 format.If the supplied
ConversionRulesobject hasConversionRules.isAllowYearZero()returning true, then (a) a year value of zero is allowed in the supplied string, and (b) thehasNoYearZeroproperty in the result is set to false. IfConversionRules.isAllowYearZero()returns false, the (a) the year value in the supplied string must not be zero, (b) a year value of -1 in the supplied string is interpreted as representing the year before year 1, and (c) thehasNoYearZeroproperty in the result is set to true.- Parameters:
s- a string in the lexical space of xs:dateTimerules- the conversion rules to be used (determining whether year zero is allowed)- Returns:
- either a DateTimeValue representing the xs:dateTime supplied, or a ValidationFailure if the lexical value was invalid
-
makeDateTimeValue
public static ConversionResult makeDateTimeValue(int year, int month, int day, int hour, int minute, BigDecimal seconds, int tzMinutes) Creates an instance of DateTimeValue. Includes validation checks. If a validation error is detected, an instance of ValidationFailure will be returned instead.- Parameters:
year- - number of a year in the Gregorian calendar. Year zero is accepted.month- - number of a month within the specified yearday- - number of a day within the specified monthhour- - hour within the specified dayminute- - minute within the hour specifiedseconds- - second within the minute specifiedtzMinutes- - number of minutes to adjust by for the timezone- Returns:
- - an instance of DateTimeValue or ValidationFailure
-
makeDateTimeValue
public static ConversionResult makeDateTimeValue(int year, int month, int day, int hour, int minute, BigDecimal seconds) -
parse
Factory method: create a dateTime value from a supplied string, in ISO 8601 format, allowing a year value of 0 to represent the year before year 1 (that is, following the XSD 1.1 rules).The
hasNoYearZeroproperty in the result is set to false.- Parameters:
s- a string in the lexical space of xs:dateTime- Returns:
- a DateTimeValue representing the xs:dateTime supplied, including a timezone offset if present in the lexical representation
- Throws:
DateTimeParseException- if the format of the supplied string is invalid.- Since:
- 9.9
-
getPrimitiveType
Determine the primitive type of the value. This delivers the same answer as getItemType().getPrimitiveItemType(). The primitive types are the 19 primitive types of XML Schema, plus xs:integer, xs:dayTimeDuration and xs:yearMonthDuration, and xs:untypedAtomic. For external objects, the result is AnyAtomicType.- Specified by:
getPrimitiveTypein classAtomicValue- Returns:
- the primitive type
-
getYear
public int getYear()Get the year component, in its internal form (which allows a year zero)- Returns:
- the year component
-
getMonth
public int getMonth()Get the month component, 1-12- Returns:
- the month component
-
getDay
public int getDay()Get the day component, 1-31- Returns:
- the day component
-
getHour
public int getHour()Get the hour component, 0-23- Returns:
- the hour component (never 24, even if the input was specified as 24:00:00)
-
getMinute
public int getMinute()Get the minute component, 0-59- Returns:
- the minute component
-
getSecond
Get the second component, 0-59- Returns:
- the second component
-
toDateTime
Convert the value to an xs:dateTime, retaining all the components that are actually present, and substituting conventional values for components that are missing. (This method does nothing in the case of xs:dateTime, but is there to implement a method in theCalendarValueinterface).- Specified by:
toDateTimein classCalendarValue- Returns:
- the value as an xs:dateTime
-
checkValidInJavascript
Check that the value can be handled in SaxonJS- Overrides:
checkValidInJavascriptin classAtomicValue- Throws:
XPathException- if it can't be handled in SaxonJS
-
adjustToUTC
Normalize the date and time to be in timezone Z.- Parameters:
implicitTimezone- used to supply the implicit timezone, used when the value has no explicit timezone- Returns:
- in general, a new DateTimeValue in timezone Z, representing the same instant in time. Returns the original DateTimeValue if this is already in timezone Z.
- Throws:
NoDynamicContextException- if the implicit timezone is needed and is CalendarValue.MISSING_TIMEZONE or CalendarValue.NO_TIMEZONE
-
toJulianInstant
Get the Julian instant: a decimal value whose integer part is the Julian day number multiplied by the number of seconds per day, and whose fractional part is the fraction of the second. This method operates on the local time, ignoring the timezone. The caller should call normalize() before calling this method to get a normalized time.- Returns:
- the Julian instant corresponding to this xs:dateTime value
-
fromJulianInstant
public static DateTimeValue fromJulianInstant(BigDecimal instant, int tzMinutes) throws XPathException Get the DateTimeValue corresponding to a given Julian instant- Parameters:
instant- the Julian instant: a decimal value whose integer part is the Julian day number multiplied by the number of seconds per day, and whose fractional part is the fraction of the second.- Returns:
- the xs:dateTime value corresponding to the Julian instant. This will always be in timezone Z.
- Throws:
XPathException- if the result is out of range
-
randomSeed
public long randomSeed()Generate a value from the current date and time that can be used to seed a random number generator- Returns:
- a long derived arbitrarily from the current date and time
-
getCalendar
Get a Java Calendar object representing the value of this DateTime. This will respect the timezone if there is one (provided the timezone is within the range supported by theGregorianCalendarclass, which in practice means that it is not -14:00). If there is no timezone or if the timezone is out of range, the result will be in GMT.- Specified by:
getCalendarin classCalendarValue- Returns:
- a Java GregorianCalendar object representing the value of this xs:dateTime value.
-
toJavaInstant
Get a Java 8Instantcorresponding to this date and time. The value will respect the time zone offset if present, or will assume UTC otherwise.- Returns:
- an
Instantrepresenting this date and time
-
toZonedDateTime
Get a Java 8ZonedDateTimecorresponding to this date and time. The value will respect the time zone offset if present, or will assume UTC otherwise.- Returns:
- a
ZonedDateTimerepresenting this date and time, including its timezone if present, or interpreted as a UTC date/time otherwise. - Since:
- 9.9
-
toOffsetDateTime
Get a Java 8OffsetDateTimecorresponding to this date and time. The value will respect the time zone offset if present, or will assume UTC otherwise.- Returns:
- a
OffsetDateTimerepresenting this date and time, including its timezone if present, or interpreted as a UTC date/time otherwise. - Since:
- 9.9
-
toLocalDateTime
Get a Java 8LocalDateTimecorresponding to this date and time. The value will ignore any timezone offset present in this value.- Returns:
- a
LocalDateTimeequivalent to this date and time, discarding any time zone offset if present. - Since:
- 9.9
-
getPrimitiveStringValue
Convert to string- Specified by:
getPrimitiveStringValuein classAtomicValue- Returns:
- ISO 8601 representation. The value returned is the localized representation:
that is it uses the timezone contained within the value itself. In the case
of a year earlier than year 1, the value output is the internally-held year,
unless the
hasNoYearZeroflag is set, in which case it is the internal year minus one.
-
toDateValue
Extract the Date part- Returns:
- a DateValue representing the date part of the dateTime, retaining the timezone or its absence
-
toTimeValue
Extract the Time part- Returns:
- a TimeValue representing the date part of the dateTime, retaining the timezone or its absence
-
getCanonicalLexicalRepresentation
Get the canonical lexical representation as defined in XML Schema. This is not always the same as the result of casting to a string according to the XPath rules. For an xs:dateTime it is the date/time adjusted to UTC.- Specified by:
getCanonicalLexicalRepresentationin interfaceAtomicSequence- Overrides:
getCanonicalLexicalRepresentationin classAtomicValue- Returns:
- the canonical lexical representation as defined in XML Schema
-
withMetadata
Make a copy of this date, time, or dateTime value, but with a new type label- Specified by:
withMetadatain classAtomicValue- Parameters:
metadata- the type label to be attached to the new copy. It is the caller's responsibility to ensure that the value actually conforms to the rules for this type.- Returns:
- the copied value
-
adjustTimezone
Return a new dateTime with the same normalized value, but in a different timezone.- Specified by:
adjustTimezonein classCalendarValue- Parameters:
timezone- the new timezone offset, in minutes- Returns:
- the date/time in the new timezone. This will be a new DateTimeValue unless no change was required to the original value
-
add
Add a duration to a dateTime- Specified by:
addin classCalendarValue- Parameters:
duration- the duration to be added (possibly negative)- Returns:
- the new date
- Throws:
XPathException- if the duration is an xs:duration, as distinct from a subclass thereof
-
subtract
public DayTimeDurationValue subtract(CalendarValue other, XPathContext context) throws XPathException Determine the difference between two points in time, as a duration- Overrides:
subtractin classCalendarValue- Parameters:
other- the other point in timecontext- the XPath dynamic context- Returns:
- the duration as an xs:dayTimeDuration
- Throws:
XPathException- for example if one value is a date and the other is a time
-
secondsSinceEpoch
-
getComponent
Get a component of the value. Returns null if the timezone component is requested and is not present.- Overrides:
getComponentin classAtomicValue- Parameters:
component- identifies the required component- Returns:
- the value of the requested component of this value
- Throws:
XPathException- if a dynamic error occurs
-
isSupported
- Specified by:
isSupportedin interfaceTemporalAccessor
-
getLong
Gets the value of the specified field as along.This queries the date-time for the value of the specified field. The returned value may be outside the valid range of values for the field. If the date-time cannot return the value, because the field is unsupported or for some other reason, an exception will be thrown.
The specification requires some fields (for example
ChronoField.EPOCH_DAYto reflect the local time. The Saxon implementation does not have access to the local time, so it adjusts to UTC instead.- Specified by:
getLongin interfaceTemporalAccessor- Parameters:
field- the field to get, not null- Returns:
- the value for the field
- Throws:
DateTimeException- if a value for the field cannot be obtainedUnsupportedTemporalTypeException- if the field is not supportedArithmeticException- if numeric overflow occursNote: Implementations must check and handle all fields defined in
ChronoField. If the field is supported, then the value of the field must be returned. If unsupported, then anUnsupportedTemporalTypeExceptionmust be thrown.If the field is not a
ChronoField, then the result of this method is obtained by invokingTemporalField.getFrom(TemporalAccessor)passingthisas the argument.Implementations must ensure that no observable state is altered when this read-only method is invoked.
-
compareTo
Compare the value to another dateTime value, following the XPath comparison semantics- Specified by:
compareToin classCalendarValue- Parameters:
other- The other dateTime valueimplicitTimezone- The implicit timezone to be used for a value with no timezone- 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 values in the implicit timezone (the Comparable interface requires a total ordering).
- Throws:
ClassCastException- if the other value is not a DateTimeValue (the parameter is declared as CalendarValue to satisfy the interface)NoDynamicContextException- if the implicit timezone is needed and is not available
-
getXPathComparable
public XPathComparable getXPathComparable(StringCollator collator, int implicitTimezone, int specVersion) throws NoDynamicContextException Description copied from class:AtomicValueGet an object value that implements the XPath equality and ordering comparison semantics for this value. A collation is supplied for comparing strings, and an implicit timezone for comparing date/time values that have no saved timezone. An atomic value may return itself as the result, provided that its ordering rules are independent of the collation and timezone, and provided that it implements the XPathComparable interface: which means that its compareTo, equals, and hashCode methods must be compatible with the rules for XPath value comparisons.- Specified by:
getXPathComparablein classAtomicValue- Parameters:
collator- the collation to be used when comparing stringsimplicitTimezone- the implicit timezone in the dynamic context, used when comparing dates/times with and without timezonespecVersion- the version of the XPath specification (31 for 3.1, 40 for 4.0)- Returns:
- an Object that implements the XPath value comparison semantics with respect to this atomic value. For an atomic type that is not ordered (according to XPath rules), return null.
- Throws:
NoDynamicContextException- if the supplied implicit timezone is "NO_TIMEZONE" (meaning unknown), and the implicit timezone is actually required because the value in question is a date/time value with no timezone. This can cause a failure to evaluate expressions statically (because the implicit timezone is not known statically), and it will then be caught, meaning that the expression has to be evaluated dynamically.
-
compareTo
Context-free comparison of two DateTimeValue values. For this to work, the two values must either both have a timezone or both have none.- Specified by:
compareToin interfaceComparable<XPathComparable>- Parameters:
v2- the other value- Returns:
- the result of the comparison: -1 if the first is earlier, 0 if they are equal, +1 if the first is later
- Throws:
ClassCastException- if the values are not comparable (which might be because no timezone is available)
-
getSchemaComparable
-
equals
Context-free comparison of two dateTime values- Overrides:
equalsin classAtomicValue- Parameters:
o- the other date time value- Returns:
- true if the two values represent the same instant in time. Return false if one value has a timezone and the other does not (this is the result needed when using keys in a map, and also the result needed for XSD comparisons for example in enumeration facets and identity constraints)
-
hashCode
public int hashCode()Hash code for context-free comparison of date time values. Note that equality testing and therefore hashCode() works only for values with a timezone- Overrides:
hashCodein classAtomicValue- Returns:
- a hash code
-
computeHashCode
public static int computeHashCode(int year, int month, int day, int hour, int minute, BigDecimal second, int tzMinutes)
-