public abstract class GDateValue extends CalendarValue
Modifier and Type | Class and Description |
---|---|
static class |
GDateValue.GDateComparable |
Modifier and Type | Field and Description |
---|---|
protected byte |
day |
protected static byte[] |
daysPerMonth
Test whether a candidate date is actually a valid date in the proleptic Gregorian calendar
|
protected boolean |
hasNoYearZero |
protected byte |
month |
protected static short[] |
monthData |
protected int |
year |
MISSING_TIMEZONE, NO_TIMEZONE
typeLabel
Constructor and Description |
---|
GDateValue() |
Modifier and Type | Method and Description |
---|---|
void |
checkValidInJavascript()
Check that the value can be handled in Saxon-JS
|
int |
compareTo(CalendarValue other,
int implicitTimezone)
Compare this value to another value of the same type, using the supplied context object
to get the implicit timezone if required.
|
boolean |
equals(java.lang.Object o)
The equals() methods on atomic values is defined to follow the semantics of eq when applied
to two atomic values.
|
java.util.GregorianCalendar |
getCalendar()
Get a Java Calendar object that represents this date/time value.
|
AtomicValue |
getComponent(AccessorFn.Component component)
Get a component of the value.
|
byte |
getDay()
Get the day component of the date (in local form)
|
byte |
getMonth()
Get the month component of the date (in local form)
|
GDateValue.GDateComparable |
getSchemaComparable() |
XPathComparable |
getXPathComparable(StringCollator collator,
int implicitTimezone)
Get an object value that implements the XPath equality and ordering comparison semantics for this value.
|
int |
getYear()
Get the year component of the date (in local form)
|
int |
hashCode()
Returns a hash code value for the object.
|
static boolean |
isLeapYear(int year)
Test whether a year is a leap year
|
static boolean |
isValidDate(int year,
int month,
int day)
Determine whether a given date is valid
|
protected static ConversionResult |
setLexicalValue(GDateValue d,
UnicodeString s,
boolean allowYearZero)
Initialize the DateValue using a character string in the format yyyy-mm-dd and an optional time zone.
|
DateTimeValue |
toDateTime()
Convert to DateTime.
|
add, adjustTimezone, adjustTimezone, appendString, appendTimezone, appendTimezone, appendTwoDigits, asMapKey, getTimezoneInMinutes, getXMLGregorianCalendar, getXPathMatchKey, hasTimezone, identityHashCode, isIdentical, makeCalendarValue, removeTimezone, setTimezoneInMinutes, subtract
asAtomic, atomize, checkPermittedContents, copyAsSubType, effectiveBooleanValue, getCanonicalLexicalRepresentation, getCardinality, getGenre, getItemType, getLength, getPrimitiveStringValue, getPrimitiveType, getUnicodeStringValue, getUType, head, isIdentical, isNaN, isUntypedAtomic, itemAt, iterate, iterator, setTypeLabel, show, toShortString, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
asAtomic
getStringValue, isStreamed, reduce, subsequence
asIterable, concatenate, containsNode, materialize
makeRepeatable
protected int year
protected byte month
protected byte day
protected boolean hasNoYearZero
protected static byte[] daysPerMonth
protected static final short[] monthData
public int getYear()
public byte getMonth()
public byte getDay()
public java.util.GregorianCalendar getCalendar()
CalendarValue
GregorianCalendar
class, which in practice means that it is not -14:00). If there is no timezone or if
the timezone is out of range, the result will be in GMT.getCalendar
in class CalendarValue
protected static ConversionResult setLexicalValue(GDateValue d, UnicodeString s, boolean allowYearZero)
d
- the "raw" DateValue to be populateds
- the supplied string valueallowYearZero
- true if (as in XSD 1.1) there is a year zero, false if (as in XSD 1.0) there is notpublic static boolean isValidDate(int year, int month, int day)
year
- the year (permitting year zero)month
- the month (1-12)day
- the day (1-31)public static boolean isLeapYear(int year)
year
- the year (permitting year zero)public void checkValidInJavascript() throws XPathException
checkValidInJavascript
in class AtomicValue
XPathException
- if it can't be handled in Saxon-JSpublic boolean equals(java.lang.Object o)
The hashCode() method is consistent with equals().
This implementation performs a context-free comparison: it fails with ClassCastException if one value has a timezone and the other does not.
equals
in class AtomicValue
o
- the other valuejava.lang.ClassCastException
- if the values are not comparablepublic int hashCode()
AtomicValue
hashCode
in class AtomicValue
public int compareTo(CalendarValue other, int implicitTimezone) throws NoDynamicContextException
compareTo
in class CalendarValue
other
- the value to be comparedimplicitTimezone
- the implicit timezone to be used for a value with no timezoneNoDynamicContextException
- if the result depends on the implicit timezone and
the supplied timezone is CalendarValue.MISSING_TIMEZONE
public DateTimeValue toDateTime()
toDateTime
in class CalendarValue
public GDateValue.GDateComparable getSchemaComparable()
public XPathComparable getXPathComparable(StringCollator collator, int implicitTimezone) throws NoDynamicContextException
AtomicValue
getXPathComparable
in class CalendarValue
collator
- the collation to be used when comparing stringsimplicitTimezone
- the implicit timezone in the dynamic context, used when comparing
dates/times with and without timezoneNoDynamicContextException
- if the supplied implicit timezone is "NO_TIMEZONE" (meaning
unknown), and the implicit timezone is actually required because the value in question is a date/time
value with no timezone. This can cause a failure to evaluate expressions statically (because the implicit
timezone is not known statically), and it will then be caught, meaning that the expression has to be
evaluated dynamically.public AtomicValue getComponent(AccessorFn.Component component) throws XPathException
getComponent
in class AtomicValue
component
- the required componentXPathException
- if a dynamic error occursCopyright (c) 2004-2022 Saxonica Limited. All rights reserved.