Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.sf.saxon.value
Class DateTimeValue

    java.lang.Object
      net.sf.saxon.value.Value
          net.sf.saxon.value.AtomicValue
              net.sf.saxon.value.CalendarValue
                  net.sf.saxon.value.DateTimeValue

All Implemented Interfaces:
  java.lang.Comparable, Expression, Item, java.io.Serializable, ValueRepresentation

public final class DateTimeValue
extends CalendarValue

A value of type DateTime

See Also:
  Serialized Form

Field Summary

Fields inherited from class net.sf.saxon.value.CalendarValue
`NO_TIMEZONE`

Fields inherited from class net.sf.saxon.value.Value
`EMPTY_CLASS_ARRAY`

Fields inherited from interface net.sf.saxon.om.ValueRepresentation
`EMPTY_VALUE_ARRAY`

Fields inherited from interface net.sf.saxon.expr.Expression
`EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD`

Constructor Summary
`DateTimeValue(java.util.Calendar calendar, boolean tzSpecified)` Constructor: create a dateTime value given a Java calendar object
`DateTimeValue(java.lang.CharSequence s)` Constructor: create a dateTime value from a supplied string, in ISO 8601 format
`DateTimeValue(DateValue date, TimeValue time)` Constructor: create a dateTime value given a date and a time.
`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 cc)` Compare the value to another dateTime value, following the XPath comparison semantics
`int` | `compareTo(java.lang.Object other)` Compare the value to another dateTime value.
`AtomicValue` | `convertPrimitive(BuiltInAtomicType requiredType, boolean validate, XPathContext context)` Convert to target data type
`java.lang.Object` | `convertToJava(java.lang.Class target, XPathContext context)` Convert to Java object (for passing to external functions)
`CalendarValue` | `copy()` Make a copy of this date, time, or dateTime value
`boolean` | `equals(java.lang.Object other)` Compare two (sequence) values for equality.
`static DateTimeValue` | `fromJulianInstant(java.math.BigDecimal instant)` Get the DateTimeValue corresponding to a given Julian instant
`java.util.GregorianCalendar` | `getCalendar()` Get a Calendar object representing the value of this DateTime.
`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
`ItemType` | `getItemType(TypeHierarchy th)` Determine the data type of the exprssion
`int` | `getMicrosecond()` Get the microsecond component, 0-999999
`byte` | `getMinute()` Get the minute component, 0-59
`byte` | `getMonth()` Get the month component, 1-12
`byte` | `getSecond()` Get the second component, 0-59
`java.lang.CharSequence` | `getStringValueCS()` Convert to string
`int` | `getYear()` Get the year component, in its internal form (which allows a year zero)
`int` | `hashCode()` Return a hash code to support the equals() function
`DateTimeValue` | `normalize(XPathContext cc)` Normalize the date and time to be in timezone Z.
`SecondsDurationValue` | `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
`java.math.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.

Methods inherited from class net.sf.saxon.value.CalendarValue
`appendTimezone, appendTimezone, getStringValue, getTimezoneInMinutes, hasTimezone, removeTimezone, setTimezoneInMinutes`

Methods inherited from class net.sf.saxon.value.AtomicValue
`checkPermittedContents, convert, convert, display, effectiveBooleanValue, evaluateAsString, evaluateItem, getCardinality, getImplementationMethod, getLength, getPrimitiveValue, getTypedValue, hasBuiltInType, iterate, process, schemaEquals, toString`

Methods inherited from class net.sf.saxon.value.Value
`asItem, asIterator, asValue, collapseWhitespace, convert, convertJavaObjectToXPath, getDependencies, getIterator, getParentExpression, getSpecialProperties, itemAt, iterateSubExpressions, makeQNameValue, normalizeWhitespace, optimize, promote, reduce, simplify, stringToNumber, trimWhitespace, typeCheck`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### DateTimeValue

    public DateTimeValue(java.util.Calendar calendar,
                         boolean tzSpecified)

  Constructor: create a dateTime value given a Java calendar object

Parameters:
  `calendar` - holds the date and time
  `tzSpecified` - indicates whether the timezone is specified

### DateTimeValue

    public DateTimeValue(DateValue date,
                         TimeValue time)
                  throws XPathException

  Constructor: create a dateTime value given a date and a time.

Parameters:
  `date` - the date
  `time` - the time
Throws:
  `XPathException` - if the timezones are both present and inconsistent

### DateTimeValue

    public DateTimeValue(java.lang.CharSequence s)
                  throws XPathException

  Constructor: create a dateTime value from a supplied string, in ISO 8601 format

### DateTimeValue

    public DateTimeValue(int year,
                         byte month,
                         byte day,
                         byte hour,
                         byte minute,
                         byte second,
                         int microsecond,
                         int tz)

  Constructor: construct a DateTimeValue from its components. This constructor performs no validation.

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 `CalendarValue.NO_TIMEZONE` if there is no timezone component.

Method Detail

### getCurrentDateTime

    public static DateTimeValue getCurrentDateTime(XPathContext context)

  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.

### getYear

    public int getYear()

  Get the year component, in its internal form (which allows a year zero)

### getMonth

    public byte getMonth()

  Get the month component, 1-12

### getDay

    public byte getDay()

  Get the day component, 1-31

### getHour

    public byte getHour()

  Get the hour component, 0-23

### getMinute

    public byte getMinute()

  Get the minute component, 0-59

### getSecond

    public byte getSecond()

  Get the second component, 0-59

### getMicrosecond

    public int getMicrosecond()

  Get the microsecond component, 0-999999

### toDateTime

    public 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

  Specified by:
    `toDateTime` in class `CalendarValue`

### normalize

    public DateTimeValue normalize(XPathContext cc)

  Normalize the date and time to be in timezone Z.

  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.

### toJulianInstant

    public java.math.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. This method operates on the local time, ignoring the timezone. The caller should call normalize() before calling this method to get a normalized time.

### fromJulianInstant

    public static DateTimeValue fromJulianInstant(java.math.BigDecimal instant)

  Get the DateTimeValue corresponding to a given Julian instant

### getCalendar

    public java.util.GregorianCalendar getCalendar()

  Get a Calendar object representing the value of this DateTime. This will respect the timezone if there is one, or be in GMT otherwise.

  Specified by:
    `getCalendar` in class `CalendarValue`
  Returns:
    A Calendar object representing the date and time. Note that Java can only represent the time to millisecond precision, and that it does not support the full range of timezones required by XPath (-14:00 to +14:00)

### convertPrimitive

    public AtomicValue convertPrimitive(BuiltInAtomicType requiredType,
                                        boolean validate,
                                        XPathContext context)

  Convert to target data type

  Specified by:
    `convertPrimitive` in class `AtomicValue`
  Parameters:
    `requiredType` - an integer identifying the required atomic type
    `context` -
    `validate` - true if validation is required. If set to false, the caller guarantees that the value is valid for the target data type, and that further validation is therefore not required. Note that a validation failure may be reported even if validation was not requested.
  Returns:
    an AtomicValue, a value of the required type; or an ErrorValue

### getStringValueCS

    public java.lang.CharSequence getStringValueCS()

  Convert to string

  Specified by:
    `getStringValueCS` in interface `Item`
  Overrides:
    `getStringValueCS` in class `AtomicValue`
  Returns:
    ISO 8601 representation. The value returned is the localized representation, that is it uses the timezone contained within the value itself.

### getItemType

    public ItemType getItemType(TypeHierarchy th)

  Determine the data type of the exprssion

  Specified by:
    `getItemType` in interface `Expression`
  Overrides:
    `getItemType` in class `Value`
  Parameters:
    `th` -
  Returns:
    Type.DATE_TIME,

### copy

    public CalendarValue copy()

  Make a copy of this date, time, or dateTime value

  Specified by:
    `copy` in class `CalendarValue`

### adjustTimezone

    public CalendarValue adjustTimezone(int timezone)

  Return a new dateTime with the same normalized value, but in a different timezone. This is called only for a DateTimeValue that has an explicit timezone

  Specified by:
    `adjustTimezone` in class `CalendarValue`
  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

    public CalendarValue add(DurationValue duration)
                      throws XPathException

  Add a duration to a dateTime

  Specified by:
    `add` in class `CalendarValue`
  Parameters:
    `duration` - the duration to be added (may be negative)
  Returns:
    the new date
  Throws:
    `XPathException` - if the duration is an xs:duration, as distinct from a subclass thereof

### subtract

    public SecondsDurationValue subtract(CalendarValue other,
                                         XPathContext context)
                                  throws XPathException

  Determine the difference between two points in time, as a duration

  Overrides:
    `subtract` in class `CalendarValue`
  Parameters:
    `other` - the other point in time
    `context` -
  Returns:
    the duration as an xdt:dayTimeDuration
  Throws:
    `XPathException` - for example if one value is a date and the other is a time

### convertToJava

    public java.lang.Object convertToJava(java.lang.Class target,
                                          XPathContext context)
                                   throws XPathException

  Convert to Java object (for passing to external functions)

  Overrides:
    `convertToJava` in class `Value`
  Throws:
    `XPathException`

### getComponent

    public AtomicValue getComponent(int component)
                             throws XPathException

  Get a component of the value. Returns null if the timezone component is requested and is not present.

  Overrides:
    `getComponent` in class `AtomicValue`
  Throws:
    `XPathException`

### compareTo

    public int compareTo(java.lang.Object other)

  Compare the value to another dateTime value.

  This method is not used for XPath comparisons because it does not have access to the implicitTimezone from the dynamic context. It is available for schema comparisons, although it does not currently implement the XML Schema semantics for timezone comparison (which involve partial ordering)

  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 values in the implicit timezone (the Comparable interface requires a total ordering).
  Throws:
    `java.lang.ClassCastException` - if the other value is not a DateTimeValue (the parameter is declared as Object to satisfy the Comparable interface)

### compareTo

    public int compareTo(CalendarValue other,
                         XPathContext cc)

  Compare the value to another dateTime value, following the XPath comparison semantics

  Specified by:
    `compareTo` in class `CalendarValue`
  Parameters:
    `other` - The other dateTime value
    `cc` - A ConversionContext used to supply the implicit 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:
    `java.lang.ClassCastException` - if the other value is not a DateTimeValue (the parameter is declared as Object to satisfy the Comparable interface)

### equals

    public boolean equals(java.lang.Object other)

  Description copied from class: `Value`
  Compare two (sequence) values for equality. This supports identity constraints in XML Schema, which allow list-valued elements and attributes to participate in key and uniqueness constraints. This method returns false if any error occurs during the comparison, or if any of the items in either sequence is a node rather than an atomic value.

  Overrides:
    `equals` in class `Value`

### hashCode

    public int hashCode()

  Description copied from class: `Value`
  Return a hash code to support the equals() function

  Overrides:
    `hashCode` in class `Value`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD