public final class DateTimeValue extends CalendarValue implements Comparable
Modifier and Type | Field and Description |
---|---|
static DateTimeValue |
EPOCH
Fixed date/time used by Java (and Unix) as the origin of the universe: 1970-01-01
|
MISSING_TIMEZONE, NO_TIMEZONE
NaN_MATCH_KEY, typeLabel
Constructor and Description |
---|
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,
boolean xsd10Check)
Constructor: construct a DateTimeValue from its components.
|
Modifier and Type | Method and Description |
---|---|
DateTimeValue |
add(DurationValue duration)
Add a duration to a dateTime
|
DateTimeValue |
adjustTimezone(int timezone)
Return a new dateTime with the same normalized value, but
in a different timezone.
|
DateTimeValue |
adjustToUTC(int implicitTimezone)
Normalize the date and time to be in timezone Z.
|
int |
compareTo(CalendarValue other,
int implicitTimezone)
Compare the value to another dateTime value, following the XPath comparison semantics
|
int |
compareTo(Object v2)
Context-free comparison of two DateTimeValue values.
|
ValidationFailure |
convertToSubType(BuiltInAtomicType subtype)
Convert the value to a built-in subtype of xs:dateTime
|
DateTimeValue |
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 |
fromJavaTime(long time)
Factory method: create a dateTime value given a Java time, expressed in milliseconds since 1970.
|
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.
|
AtomicValue |
getComponent(AccessorFn.Component 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()
Get a Comparable value that implements the XML Schema ordering comparison semantics for this value.
|
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.
|
boolean |
isXsd10Rules()
Ask whether this value uses the XSD 1.0 rules (which don't allow year zero) or the XSD 1.1 rules (which do).
|
static ConversionResult |
makeDateTimeValue(CharSequence s,
ConversionRules rules)
Factory method: create a dateTime value from a supplied string, in
ISO 8601 format
|
static DateTimeValue |
makeDateTimeValue(DateValue date,
TimeValue time)
Factory method: create a dateTime value given a date and a time.
|
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
|
adjustTimezone, appendTimezone, appendTimezone, asMapKey, getComparisonKey, getTimezoneInMinutes, getXMLGregorianCalendar, getXPathComparable, hasTimezone, identityHashCode, isIdentical, makeCalendarValue, removeTimezone, setTimezoneInMinutes
asAtomic, atomize, checkPermittedContents, effectiveBooleanValue, getCardinality, getItemType, getStringValue, getStringValueCS, getUType, head, isIdentical, isNaN, itemAt, iterate, iterator, process, setTypeLabel, toString
getLength, reduce, subsequence
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
asAtomic
getLength
reduce, subsequence
public static final DateTimeValue EPOCH
public DateTimeValue(Calendar calendar, boolean tzSpecified)
calendar
- holds the date and timetzSpecified
- indicates whether the timezone is specifiedpublic DateTimeValue(int year, byte month, byte day, byte hour, byte minute, byte second, int microsecond, int tz, boolean xsd10Check)
year
- The year as held internally (note that the year before 1AD is 0)month
- The month, 1-12day
- The day 1-31hour
- the hour value, 0-23minute
- the minutes value, 0-59second
- the seconds value, 0-59microsecond
- the number of microseconds, 0-999999tz
- the timezone displacement in minutes from UTC. Supply the value
CalendarValue.NO_TIMEZONE
if there is no timezone component.xsd10Check
- true if the dateTime value should behave under XSD 1.0 rules, that is,
negative dates assume there is no year zero. (Not that regardless of this
setting, the year argument is set on the basis that the year before +1 is
supplied as zero; but if the xsd10Check flag is set, this value will be displayed
with a year of -1.)public static DateTimeValue getCurrentDateTime(XPathContext context)
context
- the XPath dynamic context. May be null, in which case
the current date and time are taken directly from the system clockpublic static DateTimeValue fromJavaDate(Date suppliedDate) throws XPathException
suppliedDate
- holds the date and timeXPathException
- if a dynamic error occurspublic static DateTimeValue fromJavaTime(long time) throws XPathException
time
- the time in milliseconds since the epochXPathException
- if a dynamic error occurspublic static DateTimeValue makeDateTimeValue(DateValue date, TimeValue time) throws XPathException
date
- the datetime
- the timeXPathException
- if the timezones are both present and inconsistentpublic static ConversionResult makeDateTimeValue(CharSequence s, ConversionRules rules)
s
- a string in the lexical space of xs:dateTimerules
- the conversion rules to be used (determining whether year zero is allowed)public ValidationFailure convertToSubType(BuiltInAtomicType subtype)
subtype
- the target subtypepublic BuiltInAtomicType getPrimitiveType()
getPrimitiveType
in class AtomicValue
public int getYear()
public byte getMonth()
public byte getDay()
public byte getHour()
public byte getMinute()
public byte getSecond()
public int getMicrosecond()
public DateTimeValue toDateTime()
CalendarValue
interface).toDateTime
in class CalendarValue
public boolean isXsd10Rules()
public DateTimeValue adjustToUTC(int implicitTimezone) throws NoDynamicContextException
implicitTimezone
- used to supply the implicit timezone, used when the value has
no explicit timezoneNoDynamicContextException
- if the implicit timezone is needed and is CalendarValue.MISSING_TIMEZONE
or CalendarValue.NO_TIMEZONEpublic BigDecimal toJulianInstant()
public static DateTimeValue fromJulianInstant(BigDecimal instant)
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.public GregorianCalendar getCalendar()
getCalendar
in class CalendarValue
public CharSequence getPrimitiveStringValue()
getPrimitiveStringValue
in class AtomicValue
public DateValue toDateValue()
public TimeValue toTimeValue()
public CharSequence getCanonicalLexicalRepresentation()
getCanonicalLexicalRepresentation
in interface AtomicSequence
getCanonicalLexicalRepresentation
in class AtomicValue
public DateTimeValue copyAsSubType(AtomicType typeLabel)
copyAsSubType
in class AtomicValue
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.public DateTimeValue adjustTimezone(int timezone)
adjustTimezone
in class CalendarValue
timezone
- the new timezone offset, in minutespublic DateTimeValue add(DurationValue duration) throws XPathException
add
in class CalendarValue
duration
- the duration to be added (may be negative)XPathException
- if the duration is an xs:duration, as distinct from
a subclass thereofpublic DayTimeDurationValue subtract(CalendarValue other, XPathContext context) throws XPathException
subtract
in class CalendarValue
other
- the other point in timecontext
- the XPath dynamic contextXPathException
- for example if one value is a date and the other is a timepublic AtomicValue getComponent(AccessorFn.Component component) throws XPathException
getComponent
in class AtomicValue
component
- XPathException
- if a dynamic error occurspublic int compareTo(CalendarValue other, int implicitTimezone) throws NoDynamicContextException
compareTo
in class CalendarValue
other
- The other dateTime valueimplicitTimezone
- The implicit timezone to be used for a value with no timezoneClassCastException
- 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 availablepublic int compareTo(Object v2)
compareTo
in interface Comparable
v2
- the other valueClassCastException
- if the values are not comparable (which might be because
no timezone is available)public Comparable getSchemaComparable()
AtomicValue
In the case of data types that are partially ordered, the returned Comparable extends the standard
semantics of the compareTo() method by returning the value SequenceTool.INDETERMINATE_ORDERING
when there
is no defined order relationship between two given values. This value is also returned when two values
of different types are compared.
getSchemaComparable
in interface AtomicSequence
getSchemaComparable
in class AtomicValue
public boolean equals(Object o)
equals
in class AtomicValue
o
- the other date time valueCopyright (c) 2004-2014 Saxonica Limited. All rights reserved.