Package net.sf.saxon.value
Class CalendarValue
java.lang.Object
net.sf.saxon.value.Value
net.sf.saxon.value.AtomicValue
net.sf.saxon.value.CalendarValue
- All Implemented Interfaces:
Serializable
,Comparable
,Expression
,Item
,ValueRepresentation
- Direct Known Subclasses:
DateTimeValue
,DateValue
,TimeValue
Abstract superclass for Date, Time, and DateTime.
- See Also:
-
Field Summary
FieldsFields inherited from class net.sf.saxon.value.Value
EMPTY_CLASS_ARRAY
Fields inherited from interface net.sf.saxon.expr.Expression
EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD
Fields inherited from interface net.sf.saxon.om.ValueRepresentation
EMPTY_VALUE_ARRAY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract CalendarValue
add
(DurationValue duration) Add a duration to this date/time valueabstract CalendarValue
adjustTimezone
(int tz) Return a new date, time, or dateTime with the same normalized value, but in a different timezone(package private) static void
appendString
(FastStringBuffer sb, int value, int size) Append an integer, formatted with leading zeros to a fixed size, to a string bufferstatic final void
appendTimezone
(int tz, FastStringBuffer sb) final void
Add a string representation of the timezone, typically formatted as "Z" or "+03:00" or "-10:00", to a supplied string buffer(package private) static void
appendTwoDigits
(FastStringBuffer sb, int value) Append an integer, formatted as two digits, to a string bufferabstract int
compareTo
(CalendarValue other, Configuration config) Compare this value to another value of the same type, using the supplied ConversionContext to get the implicit timezone if required.abstract CalendarValue
copy()
Make a copy of this date, time, or dateTime valueabstract GregorianCalendar
Get a Java Calendar object that represents this date/time value.abstract ComparisonKey
getComparisonKey
(Configuration config) Get a comparison key for this value.final String
Convert the value to a stringfinal int
Get the timezone value held in this object.final boolean
Determine whether this value includes a timezonefinal CalendarValue
Return a date, time, or dateTime with the same localized value, but without the timezone componentfinal void
setTimezoneInMinutes
(int minutes) Modify the timezone value held in this object.subtract
(CalendarValue other, XPathContext context) Determine the difference between two points in time, as a durationabstract DateTimeValue
Convert the value to a DateTime, retaining all the components that are actually present, and substituting conventional values for components that are missingMethods inherited from class net.sf.saxon.value.AtomicValue
checkPermittedContents, convert, convert, convertPrimitive, display, effectiveBooleanValue, evaluateAsString, evaluateItem, getCardinality, getComponent, getImplementationMethod, getLength, getPrimitiveValue, getStringValueCS, getTypedValue, hasBuiltInType, iterate, process, toString
Methods inherited from class net.sf.saxon.value.Value
asItem, asIterator, asValue, convert, convertJavaObjectToXPath, convertToJava, equals, getDependencies, getItemType, getIterator, getParentExpression, getSpecialProperties, hashCode, itemAt, iterateSubExpressions, makeQNameValue, optimize, promote, reduce, simplify, stringToNumber, typeCheck
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Comparable
compareTo
-
Field Details
-
NO_TIMEZONE
public static final int NO_TIMEZONE- See Also:
-
-
Constructor Details
-
CalendarValue
public CalendarValue()
-
-
Method Details
-
hasTimezone
public final boolean hasTimezone()Determine whether this value includes a timezone- Returns:
- true if there is a timezone in the value, false if not
-
setTimezoneInMinutes
public final void setTimezoneInMinutes(int minutes) Modify the timezone value held in this object. This must be done only while the value is being constructed.- Parameters:
minutes
- The timezone offset from GMT in minutes, positive or negative; or the special value NO_TIMEZONE indicating that the value is not in a timezone (this is the default if this method is not called)
-
toDateTime
Convert the value to a DateTime, retaining all the components that are actually present, and substituting conventional values for components that are missing -
getTimezoneInMinutes
public final int getTimezoneInMinutes()Get the timezone value held in this object.- Returns:
- The timezone offset from GMT in minutes, positive or negative; or the special value NO_TIMEZONE indicating that the value is not in a timezone
-
getStringValue
Convert the value to a string- Specified by:
getStringValue
in interfaceItem
- Specified by:
getStringValue
in interfaceValueRepresentation
- Specified by:
getStringValue
in classAtomicValue
- Returns:
- the string value of the item
- See Also:
-
getCalendar
Get a Java Calendar object that represents this date/time value. The Calendar object will be newly created for the purpose- 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)
-
add
Add a duration to this date/time value- Parameters:
duration
- the duration to be added (which might be negative)- Returns:
- a new date/time value representing the result of adding the duration. The original object is not modified.
- Throws:
XPathException
-
subtract
public SecondsDurationValue subtract(CalendarValue other, XPathContext context) throws XPathException Determine the difference between two points in time, as a duration- Parameters:
other
- the other point in timecontext
- the dynamic context, used to obtain timezone information. May be set to null only if both values contain an explicit timezone, or if neither does so.- Returns:
- the duration as an xdt:dayTimeDuration
- Throws:
XPathException
- for example if one value is a date and the other is a time
-
removeTimezone
Return a date, time, or dateTime with the same localized value, but without the timezone component- Returns:
- the result of removing the timezone
-
adjustTimezone
Return a new date, time, or dateTime with the same normalized value, but in a different timezone- Parameters:
tz
- the new timezone, in minutes- Returns:
- the date/time in the new timezone
-
copy
Make a copy of this date, time, or dateTime value -
compareTo
Compare this value to another value of the same type, using the supplied ConversionContext to get the implicit timezone if required. -
getComparisonKey
Get a comparison key for this value. Two values are equal if and only if they their comparison keys are equal -
appendTimezone
Add a string representation of the timezone, typically formatted as "Z" or "+03:00" or "-10:00", to a supplied string buffer- Parameters:
sb
- The StringBuffer that will be updated with the resulting string representation
-
appendTimezone
-
appendString
Append an integer, formatted with leading zeros to a fixed size, to a string buffer- Parameters:
sb
- the string buffervalue
- the integer to be formattedsize
- the number of digits required (max 9)
-
appendTwoDigits
Append an integer, formatted as two digits, to a string buffer- Parameters:
sb
- the string buffervalue
- the integer to be formatted (must be in the range 0..99
-