net.sf.saxon.value
public final class DateTimeValue extends CalendarValue implements Comparable
Field Summary | |
---|---|
static DateTimeValue | EPOCH
Fixed date/time used by Java (and Unix) as the origin of the universe: 1970-01-01 |
Constructor Summary | |
---|---|
DateTimeValue(Calendar calendar, boolean tzSpecified)
Constructor: create a dateTime value given a Java calendar object
| |
DateTimeValue(int year, byte month, byte day, byte hour, byte minute, byte second, int microsecond, int tz)
Constructor: construct a DateTimeValue from its components.
|
Method Summary | |
---|---|
CalendarValue | add(DurationValue duration)
Add a duration to a dateTime
|
CalendarValue | adjustTimezone(int timezone)
Return a new dateTime with the same normalized value, but
in a different timezone.
|
int | compareTo(CalendarValue other, XPathContext context)
Compare the value to another dateTime value, following the XPath comparison semantics
|
int | compareTo(Object v2)
Context-free comparison of two DateTimeValue values. |
ConversionResult | convertPrimitive(BuiltInAtomicType requiredType, boolean validate, XPathContext context)
Convert to target data type
|
ValidationFailure | convertToSubType(BuiltInAtomicType subtype)
Convert the value to a built-in subtype of xs:dateTime |
AtomicValue | copyAsSubType(AtomicType typeLabel)
Make a copy of this date, time, or dateTime value, but with a new type label
|
boolean | equals(Object o)
Context-free comparison of two dateTime values |
static DateTimeValue | fromJavaDate(Date suppliedDate)
Factory method: create a dateTime value given a Java Date object. |
static DateTimeValue | fromJulianInstant(BigDecimal instant)
Get the DateTimeValue corresponding to a given Julian instant
|
GregorianCalendar | getCalendar()
Get a Java Calendar object representing the value of this DateTime. |
CharSequence | getCanonicalLexicalRepresentation()
Get the canonical lexical representation as defined in XML Schema. |
ComparisonKey | getComparisonKey(XPathContext context)
Get a comparison key for this value. |
AtomicValue | getComponent(int component)
Get a component of the value. |
static DateTimeValue | getCurrentDateTime(XPathContext context)
Get the dateTime value representing the nominal
date/time of this transformation run. |
byte | getDay()
Get the day component, 1-31
|
byte | getHour()
Get the hour component, 0-23
|
int | getMicrosecond()
Get the microsecond component, 0-999999
|
byte | getMinute()
Get the minute component, 0-59
|
byte | getMonth()
Get the month component, 1-12
|
CharSequence | getPrimitiveStringValue()
Convert to string
|
BuiltInAtomicType | getPrimitiveType()
Determine the primitive type of the value. |
Comparable | getSchemaComparable() |
byte | getSecond()
Get the second component, 0-59
|
int | getYear()
Get the year component, in its internal form (which allows a year zero)
|
int | hashCode()
Hash code for context-free comparison of date time values. |
static int | hashCode(int year, byte month, byte day, byte hour, byte minute, byte second, int microsecond, int tzMinutes) |
static DateTimeValue | makeDateTimeValue(DateValue date, TimeValue time)
Factory method: create a dateTime value given a date and a time.
|
static ConversionResult | makeDateTimeValue(CharSequence s)
Factory method: create a dateTime value from a supplied string, in
ISO 8601 format
|
DateTimeValue | normalize(XPathContext cc)
Normalize the date and time to be in timezone Z.
|
DayTimeDurationValue | subtract(CalendarValue other, XPathContext context)
Determine the difference between two points in time, as a duration
|
DateTimeValue | toDateTime()
Convert the value to a DateTime, retaining all the components that are actually present, and
substituting conventional values for components that are missing. |
DateValue | toDateValue()
Extract the Date part |
BigDecimal | 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.
|
TimeValue | toTimeValue()
Extract the Time part |
Parameters: calendar holds the date and time tzSpecified indicates whether the timezone is specified
Parameters: year The year as held internally (note that the year before 1AD is 0) month The month, 1-12 day The day 1-31 hour the hour value, 0-23 minute the minutes value, 0-59 second the seconds value, 0-59 microsecond the number of microseconds, 0-999999 tz the timezone displacement in minutes from UTC. Supply the value NO_TIMEZONE if there is no timezone component.
Parameters: duration the duration to be added (may be negative)
Returns: the new date
Throws: net.sf.saxon.trans.XPathException if the duration is an xs:duration, as distinct from a subclass thereof
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
Parameters: other The other dateTime value context XPath dynamic evaluation context
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
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)
Parameters: requiredType an integer identifying the required atomic type context the XPath dynamic context
Returns: an AtomicValue, a value of the required type; or an ErrorValue
Parameters: subtype the target subtype
Returns: null if the conversion succeeds; a ValidationFailure describing the failure if it fails.
Parameters: typeLabel 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.
Parameters: o the other date time value
Returns: true if the two values represent the same instant in time
Throws: ClassCastException if one of the values has a timezone and the other does not
Parameters: suppliedDate holds the date and time
Returns: the corresponding xs:dateTime value
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.
Returns: a Java GregorianCalendar object representing the value of this xs:dateTime value.
Returns: the canonical lexical representation as defined in XML Schema
Parameters: context XPath dynamic context
Throws: NoDynamicContextException if the implicit timezone is needed and is not available
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
Returns: the day component
Returns: the hour component (never 24, even if the input was specified as 24:00:00)
Returns: the microsecond component
Returns: the minute component
Returns: the month component
Returns: ISO 8601 representation. The value returned is the localized representation, that is it uses the timezone contained within the value itself.
Returns: the second component
Returns: the year component
Returns: a hash code
Parameters: date the date time the time
Returns: the dateTime with the given components. If either component is null, returns null
Throws: XPathException if the timezones are both present and inconsistent
Parameters: s a string in the lexical space of xs:dateTime
Returns: either a DateTimeValue representing the xs:dateTime supplied, or a ValidationFailure if the lexical value was invalid
Parameters: cc 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 not available
Parameters: other the other point in time context the XPath dynamic context
Returns: the duration as an xs:dayTimeDuration
Throws: net.sf.saxon.trans.XPathException for example if one value is a date and the other is a time
Returns: the value as an xs:dateTime
Returns: a DateValue representing the date part of the dateTime, retaining the timezone or its absence
Returns: the Julian instant corresponding to this xs:dateTime value
Returns: a TimeValue representing the date part of the dateTime, retaining the timezone or its absence