net.sf.saxon.value

Class CalendarValue

public abstract class CalendarValue extends AtomicValue implements Comparable

Abstract superclass for Date, Time, and DateTime.
Field Summary
static intNO_TIMEZONE
Method Summary
abstract CalendarValueadd(DurationValue duration)
Add a duration to this date/time value
abstract CalendarValueadjustTimezone(int tz)
Return a new date, time, or dateTime with the same normalized value, but in a different timezone
static voidappendString(FastStringBuffer sb, int value, int size)
Append an integer, formatted with leading zeros to a fixed size, to a string buffer
voidappendTimezone(FastStringBuffer sb)
Add a string representation of the timezone, typically formatted as "Z" or "+03:00" or "-10:00", to a supplied string buffer
static voidappendTimezone(int tz, FastStringBuffer sb)
static voidappendTwoDigits(FastStringBuffer sb, int value)
Append an integer, formatted as two digits, to a string buffer
abstract intcompareTo(CalendarValue other, XPathContext context)
Compare this value to another value of the same type, using the supplied ConversionContext to get the implicit timezone if required.
abstract CalendarValuecopy()
Make a copy of this date, time, or dateTime value
abstract GregorianCalendargetCalendar()
Get a Java Calendar object that represents this date/time value.
StringgetStringValue()
Convert the value to a string
intgetTimezoneInMinutes()
Get the timezone value held in this object.
booleanhasTimezone()
Determine whether this value includes a timezone
CalendarValueremoveTimezone()
Return a date, time, or dateTime with the same localized value, but without the timezone component
voidsetTimezoneInMinutes(int minutes)
Modify the timezone value held in this object.
SecondsDurationValuesubtract(CalendarValue other, XPathContext context)
Determine the difference between two points in time, as a duration
abstract DateTimeValuetoDateTime()
Convert the value to a DateTime, retaining all the components that are actually present, and substituting conventional values for components that are missing

Field Detail

NO_TIMEZONE

public static final int NO_TIMEZONE

Method Detail

add

public abstract CalendarValue add(DurationValue duration)
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

adjustTimezone

public abstract CalendarValue adjustTimezone(int tz)
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

appendString

static void appendString(FastStringBuffer sb, int value, int size)
Append an integer, formatted with leading zeros to a fixed size, to a string buffer

Parameters: sb the string buffer value the integer to be formatted size the number of digits required (max 9)

appendTimezone

public final void appendTimezone(FastStringBuffer sb)
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

public static final void appendTimezone(int tz, FastStringBuffer sb)

appendTwoDigits

static void appendTwoDigits(FastStringBuffer sb, int value)
Append an integer, formatted as two digits, to a string buffer

Parameters: sb the string buffer value the integer to be formatted (must be in the range 0..99

compareTo

public abstract int compareTo(CalendarValue other, XPathContext context)
Compare this value to another value of the same type, using the supplied ConversionContext to get the implicit timezone if required.

copy

public abstract CalendarValue copy()
Make a copy of this date, time, or dateTime value

getCalendar

public abstract GregorianCalendar 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)

getStringValue

public final String getStringValue()
Convert the value to a string

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

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

removeTimezone

public final CalendarValue removeTimezone()
Return a date, time, or dateTime with the same localized value, but without the timezone component

Returns: the result of removing the timezone

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)

subtract

public SecondsDurationValue subtract(CalendarValue other, XPathContext context)
Determine the difference between two points in time, as a duration

Parameters: other the other point in time context 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: net.sf.saxon.trans.XPathException for example if one value is a date and the other is a time

toDateTime

public abstract 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