public class SaxonXMLGregorianCalendar
extends javax.xml.datatype.XMLGregorianCalendar
CalendarValue
The JAXP specification for this class defines it in terms of XML Schema 1.0 semantics.
This implementation is more aligned to the XPath 2.0 semantics of the data types.
Note that this class, unlike the representations of all other data types, is mutable.| Constructor and Description |
|---|
SaxonXMLGregorianCalendar(CalendarValue value)
Create a SaxonXMLGregorianCalendar from a Saxon CalendarValue object
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(javax.xml.datatype.Duration duration)
Add
duration to this instance. |
void |
clear()
Unset all fields to undefined.
|
java.lang.Object |
clone()
Creates and returns a copy of this object.
|
int |
compare(javax.xml.datatype.XMLGregorianCalendar xmlGregorianCalendar)
Compare two instances of W3C XML Schema 1.0 date/time datatypes
according to partial order relation defined in
W3C XML Schema 1.0 Part 2, Section 3.2.7.3,
Order relation on dateTime.
|
int |
getDay()
Return day in month or
DatatypeConstants.FIELD_UNDEFINED. |
java.math.BigInteger |
getEon()
Return high order component for XML Schema 1.0 dateTime datatype field for
year. |
java.math.BigInteger |
getEonAndYear()
Return XML Schema 1.0 dateTime datatype field for
year. |
java.math.BigDecimal |
getFractionalSecond()
Return fractional seconds.
|
int |
getHour()
Return hours or
DatatypeConstants.FIELD_UNDEFINED. |
int |
getMicrosecond()
Return microsecond precision of
getFractionalSecond(). |
int |
getMinute()
Return minutes or
DatatypeConstants.FIELD_UNDEFINED. |
int |
getMonth()
Return number of month or
DatatypeConstants.FIELD_UNDEFINED. |
int |
getSecond()
Return seconds or
DatatypeConstants.FIELD_UNDEFINED. |
int |
getTimezone()
Return timezone offset in minutes or
DatatypeConstants.FIELD_UNDEFINED if this optional field is not defined. |
java.util.TimeZone |
getTimeZone(int defaultZoneoffset)
Returns a
java.util.TimeZone for this class. |
javax.xml.namespace.QName |
getXMLSchemaType()
Return the name of the XML Schema date/time type that this instance
maps to.
|
int |
getYear()
Return low order component for XML Schema 1.0 dateTime datatype field for
year or DatatypeConstants.FIELD_UNDEFINED. |
boolean |
isValid()
Validate instance by
getXMLSchemaType() constraints. |
javax.xml.datatype.XMLGregorianCalendar |
normalize()
Normalize this instance to UTC.
|
void |
reset()
Reset this
XMLGregorianCalendar to its original values. |
void |
setCalendarValue(CalendarValue value)
Set the calendar value of this object
|
void |
setDay(int day)
Set days in month.
|
void |
setFractionalSecond(java.math.BigDecimal fractional)
Set fractional seconds.
|
void |
setHour(int hour)
Set hours.
|
void |
setMillisecond(int millisecond)
Set milliseconds.
|
void |
setMinute(int minute)
Set minutes.
|
void |
setMonth(int month)
Set month.
|
void |
setSecond(int second)
Set seconds.
|
void |
setTimezone(int offset)
Set the number of minutes in the timezone offset.
|
void |
setYear(java.math.BigInteger year)
Set low and high order component of XSD
dateTime year field. |
void |
setYear(int year)
Set year of XSD
dateTime year field. |
CalendarValue |
toCalendarValue()
Convert this SaxonXMLGregorianCalendar to a Saxon CalendarValue object
|
java.util.GregorianCalendar |
toGregorianCalendar()
Convert this
XMLGregorianCalendar to a GregorianCalendar. |
java.util.GregorianCalendar |
toGregorianCalendar(java.util.TimeZone timezone,
java.util.Locale aLocale,
javax.xml.datatype.XMLGregorianCalendar defaults)
Convert this
XMLGregorianCalendar along with provided parameters
to a GregorianCalendar instance. |
java.lang.String |
toXMLFormat()
Return the lexical representation of
this instance. |
public SaxonXMLGregorianCalendar(CalendarValue value)
value - the CalendarValuepublic void setCalendarValue(CalendarValue value)
value - the calendar valuepublic void clear()
Unset all fields to undefined.
Set all int fields to DatatypeConstants.FIELD_UNDEFINED and reference fields
to null.
clear in class javax.xml.datatype.XMLGregorianCalendarpublic void reset()
Reset this XMLGregorianCalendar to its original values.
Saxon does not attempt to reset to the initial value as defined in the specification of
the superclass, because it cannot distinguish the initial setting from subsequent changes.
This method is therefore synonymous with clear()
reset in class javax.xml.datatype.XMLGregorianCalendarpublic void setYear(java.math.BigInteger year)
Set low and high order component of XSD dateTime year field.
Unset this field by invoking the setter with a parameter value of null.
setYear in class javax.xml.datatype.XMLGregorianCalendaryear - value constraints summarized in year field of date/time field mapping table.java.lang.IllegalArgumentException - if year parameter is
outside value constraints for the field as specified in
date/time field mapping table.public void setYear(int year)
Set year of XSD dateTime year field.
Unset this field by invoking the setter with a parameter value of
DatatypeConstants.FIELD_UNDEFINED.
Note: if the absolute value of the year parameter
is less than 10^9, the eon component of the XSD year field is set to
null by this method.
setYear in class javax.xml.datatype.XMLGregorianCalendaryear - value constraints are summarized in year field of date/time field mapping table.
If year is DatatypeConstants.FIELD_UNDEFINED, then eon is set to null.public void setMonth(int month)
Set month.
Unset this field by invoking the setter with a parameter value of DatatypeConstants.FIELD_UNDEFINED.
setMonth in class javax.xml.datatype.XMLGregorianCalendarmonth - value constraints summarized in month field of date/time field mapping table.java.lang.IllegalArgumentException - if month parameter is
outside value constraints for the field as specified in
date/time field mapping table.public void setDay(int day)
Set days in month.
Unset this field by invoking the setter with a parameter value of DatatypeConstants.FIELD_UNDEFINED.
setDay in class javax.xml.datatype.XMLGregorianCalendarday - value constraints summarized in day field of date/time field mapping table.java.lang.IllegalArgumentException - if day parameter is
outside value constraints for the field as specified in
date/time field mapping table.public void setTimezone(int offset)
Set the number of minutes in the timezone offset.
Unset this field by invoking the setter with a parameter value of DatatypeConstants.FIELD_UNDEFINED.
setTimezone in class javax.xml.datatype.XMLGregorianCalendaroffset - value constraints summarized in
timezone field of date/time field mapping table.java.lang.IllegalArgumentException - if offset parameter is
outside value constraints for the field as specified in
date/time field mapping table.public void setHour(int hour)
Set hours.
Unset this field by invoking the setter with a parameter value of DatatypeConstants.FIELD_UNDEFINED.
setHour in class javax.xml.datatype.XMLGregorianCalendarhour - value constraints summarized in hour field of date/time field mapping table.java.lang.IllegalArgumentException - if hour parameter is outside value constraints for the field as specified in
date/time field mapping table.public void setMinute(int minute)
Set minutes.
Unset this field by invoking the setter with a parameter value of DatatypeConstants.FIELD_UNDEFINED.
setMinute in class javax.xml.datatype.XMLGregorianCalendarminute - value constraints summarized in minute field of date/time field mapping table.java.lang.IllegalArgumentException - if minute parameter is outside value constraints for the field as specified in
date/time field mapping table.public void setSecond(int second)
Set seconds.
Unset this field by invoking the setter with a parameter value of DatatypeConstants.FIELD_UNDEFINED.
setSecond in class javax.xml.datatype.XMLGregorianCalendarsecond - value constraints summarized in second field of date/time field mapping table.java.lang.IllegalArgumentException - if second parameter is outside value constraints for the field as specified in
date/time field mapping table.public void setMillisecond(int millisecond)
Set milliseconds.
Unset this field by invoking the setter with a parameter value of DatatypeConstants.FIELD_UNDEFINED.
setMillisecond in class javax.xml.datatype.XMLGregorianCalendarmillisecond - value constraints summarized in
millisecond field of date/time field mapping table.java.lang.IllegalArgumentException - if millisecond parameter is outside value constraints for the field as specified
in date/time field mapping table.public void setFractionalSecond(java.math.BigDecimal fractional)
Set fractional seconds.
Unset this field by invoking the setter with a parameter value of null.
setFractionalSecond in class javax.xml.datatype.XMLGregorianCalendarfractional - value constraints summarized in
fractional field of date/time field mapping table.java.lang.IllegalArgumentException - if fractional parameter is outside value constraints for the field as specified
in date/time field mapping table.public java.math.BigInteger getEon()
Return high order component for XML Schema 1.0 dateTime datatype field for
year.
null if this optional part of the year field is not defined.
Value constraints for this value are summarized in year field of date/time field mapping table.
getEon in class javax.xml.datatype.XMLGregorianCalendarXMLGregorianCalendar. The value
returned is an integer multiple of 10^9.getYear(),
getEonAndYear()public int getYear()
Return low order component for XML Schema 1.0 dateTime datatype field for
year or DatatypeConstants.FIELD_UNDEFINED.
Value constraints for this value are summarized in year field of date/time field mapping table.
getYear in class javax.xml.datatype.XMLGregorianCalendarXMLGregorianCalendar.getEon(),
getEonAndYear()public java.math.BigInteger getEonAndYear()
Return XML Schema 1.0 dateTime datatype field for
year.
Value constraints for this value are summarized in year field of date/time field mapping table.
public int getMonth()
Return number of month or DatatypeConstants.FIELD_UNDEFINED.
Value constraints for this value are summarized in month field of date/time field mapping table.
getMonth in class javax.xml.datatype.XMLGregorianCalendarXMLGregorianCalendar.public int getDay()
DatatypeConstants.FIELD_UNDEFINED.
Value constraints for this value are summarized in day field of date/time field mapping table.
getDay in class javax.xml.datatype.XMLGregorianCalendarsetDay(int)public int getTimezone()
DatatypeConstants.FIELD_UNDEFINED if this optional field is not defined.
Value constraints for this value are summarized in timezone field of date/time field mapping table.
getTimezone in class javax.xml.datatype.XMLGregorianCalendarsetTimezone(int)public int getHour()
DatatypeConstants.FIELD_UNDEFINED.
Returns DatatypeConstants.FIELD_UNDEFINED if this field is not defined.
Value constraints for this value are summarized in hour field of date/time field mapping table.
getHour in class javax.xml.datatype.XMLGregorianCalendarXMLGregorianCalendar.setTime(int, int, int)public int getMinute()
DatatypeConstants.FIELD_UNDEFINED.
Returns DatatypeConstants.FIELD_UNDEFINED if this field is not defined.
Value constraints for this value are summarized in minute field of date/time field mapping table.
getMinute in class javax.xml.datatype.XMLGregorianCalendarXMLGregorianCalendar.setTime(int, int, int)public int getSecond()
Return seconds or DatatypeConstants.FIELD_UNDEFINED.
Returns DatatypeConstants.FIELD_UNDEFINED if this field is not defined.
When this field is not defined, the optional xs:dateTime
fractional seconds field, represented by
getFractionalSecond() and XMLGregorianCalendar.getMillisecond(),
must not be defined.
Value constraints for this value are summarized in second field of date/time field mapping table.
getSecond in class javax.xml.datatype.XMLGregorianCalendarXMLGregorianCalendar.getFractionalSecond(),
XMLGregorianCalendar.getMillisecond(),
XMLGregorianCalendar.setTime(int, int, int)public int getMicrosecond()
Return microsecond precision of getFractionalSecond().
This method represents a convenience accessor to infinite
precision fractional second value returned by
getFractionalSecond(). The returned value is the rounded
down to microseconds value of
getFractionalSecond(). When getFractionalSecond()
returns null, this method must return
DatatypeConstants.FIELD_UNDEFINED.
Value constraints for this value are summarized in second field of date/time field mapping table.
XMLGregorianCalendar.getFractionalSecond(),
XMLGregorianCalendar.setTime(int, int, int)public java.math.BigDecimal getFractionalSecond()
Return fractional seconds.
null is returned when this optional field is not defined.
Value constraints are detailed in second field of date/time field mapping table.
This optional field can only have a defined value when the
xs:dateTime second field, represented by getSecond(),
does not return DatatypeConstants.FIELD_UNDEFINED.
getFractionalSecond in class javax.xml.datatype.XMLGregorianCalendarXMLGregorianCalendar.getSecond(),
XMLGregorianCalendar.setTime(int, int, int, java.math.BigDecimal)public int compare(javax.xml.datatype.XMLGregorianCalendar xmlGregorianCalendar)
Compare two instances of W3C XML Schema 1.0 date/time datatypes according to partial order relation defined in W3C XML Schema 1.0 Part 2, Section 3.2.7.3, Order relation on dateTime.
xsd:dateTime datatype field mapping to accessors of
this class are defined in
date/time field mapping table.
compare in class javax.xml.datatype.XMLGregorianCalendarxmlGregorianCalendar - Instance of XMLGregorianCalendar to comparethis XMLGregorianCalendar and
the specified xmlGregorianCalendar as
DatatypeConstants.LESSER,
DatatypeConstants.EQUAL,
DatatypeConstants.GREATER or
DatatypeConstants.INDETERMINATE.java.lang.NullPointerException - if xmlGregorianCalendar is null.public javax.xml.datatype.XMLGregorianCalendar normalize()
Normalize this instance to UTC.
2000-03-04T23:00:00+03:00 normalizes to 2000-03-04T20:00:00Z
Implements W3C XML Schema Part 2, Section 3.2.7.3 (A).
normalize in class javax.xml.datatype.XMLGregorianCalendarXMLGregorianCalendar normalized to UTC.public java.lang.String toXMLFormat()
Return the lexical representation of this instance.
The format is specified in
XML Schema 1.0 Part 2, Section 3.2.[7-14].1,
Lexical Representation".
Specific target lexical representation format is determined by
getXMLSchemaType().
toXMLFormat in class javax.xml.datatype.XMLGregorianCalendarString, representation of this XMLGregorianCalendarjava.lang.IllegalStateException - if the combination of set fields
does not match one of the eight defined XML Schema builtin date/time datatypes.public javax.xml.namespace.QName getXMLSchemaType()
Return the name of the XML Schema date/time type that this instance maps to. Type is computed based on fields that are set.
getXMLSchemaType in class javax.xml.datatype.XMLGregorianCalendarDatatypeConstants.DATETIME,
DatatypeConstants.TIME,
DatatypeConstants.DATE,
DatatypeConstants.GYEARMONTH,
DatatypeConstants.GMONTHDAY,
DatatypeConstants.GYEAR,
DatatypeConstants.GMONTH or
DatatypeConstants.GDAY.java.lang.IllegalStateException - if the combination of set fields
does not match one of the eight defined XML Schema builtin
date/time datatypes.public boolean isValid()
getXMLSchemaType() constraints.isValid in class javax.xml.datatype.XMLGregorianCalendarpublic void add(javax.xml.datatype.Duration duration)
Add duration to this instance.
The computation is specified in
XML Schema 1.0 Part 2, Appendix E,
Adding durations to dateTimes>.
date/time field mapping table
defines the mapping from XML Schema 1.0 dateTime fields
to this class' representation of those fields.
add in class javax.xml.datatype.XMLGregorianCalendarduration - Duration to add to this XMLGregorianCalendar.java.lang.NullPointerException - when duration parameter is null.public java.util.GregorianCalendar toGregorianCalendar()
Convert this XMLGregorianCalendar to a GregorianCalendar.
When this instance has an undefined field, this
conversion relies on the java.util.GregorianCalendar default
for its corresponding field. A notable difference between
XML Schema 1.0 date/time datatypes and java.util.GregorianCalendar
is that Timezone value is optional for date/time datatypes and it is
a required field for java.util.GregorianCalendar. See javadoc
for java.util.TimeZone.getDefault() on how the default
is determined. To explicitly specify the TimeZone
instance, see
toGregorianCalendar(java.util.TimeZone, Locale, javax.xml.datatype.XMLGregorianCalendar).
toGregorianCalendar in class javax.xml.datatype.XMLGregorianCalendartoGregorianCalendar(java.util.TimeZone, java.util.Locale, javax.xml.datatype.XMLGregorianCalendar)public java.util.GregorianCalendar toGregorianCalendar(java.util.TimeZone timezone,
java.util.Locale aLocale,
javax.xml.datatype.XMLGregorianCalendar defaults)
Convert this XMLGregorianCalendar along with provided parameters
to a GregorianCalendar instance.
Since XML Schema 1.0 date/time datetypes has no concept of
timezone ids or daylight savings timezone ids, this conversion operation
allows the user to explicitly specify one with
timezone parameter.
To compute the return value's TimeZone field,
timeZone is non-null,
it is the timezone field.this.getTimezone() != FIELD_UNDEFINED,
create a java.util.TimeZone with a custom timezone id
using the this.getTimezone().defaults.getTimezone() != FIELD_UNDEFINED,
create a java.util.TimeZone with a custom timezone id
using defaults.getTimezone().GregorianCalendar default timezone value
for the host is defined as specified by
java.util.TimeZone.getDefault().To ensure consistency in conversion implementations, the new
GregorianCalendar should be instantiated in following
manner.
java.util.GregorianCalendar(TimeZone,
Locale) with TimeZone set as specified above and the
Locale parameter.
Calendar.clear()GregorianCalendar.setGregorianChange(
new Date(Long.MIN_VALUE)).Calendar.set(int,int)toGregorianCalendar in class javax.xml.datatype.XMLGregorianCalendartimezone - provide Timezone. null is a legal value.aLocale - provide explicit Locale. Use default GregorianCalendar locale if
value is null.defaults - provide default field values to use when corresponding
field for this instance is FIELD_UNDEFINED or null.
If defaultsis null or a field
within the specified defaults is undefined,
just use java.util.GregorianCalendar defaults.public java.util.TimeZone getTimeZone(int defaultZoneoffset)
Returns a java.util.TimeZone for this class.
If timezone field is defined for this instance, returns TimeZone initialized with custom timezone id of zoneoffset. If timezone field is undefined, try the defaultZoneoffset that was passed in. If defaultZoneoffset is FIELD_UNDEFINED, return default timezone for this host. (Same default as java.util.GregorianCalendar).
getTimeZone in class javax.xml.datatype.XMLGregorianCalendardefaultZoneoffset - default zoneoffset if this zoneoffset is
DatatypeConstants.FIELD_UNDEFINED.public java.lang.Object clone()
Creates and returns a copy of this object.
clone in class javax.xml.datatype.XMLGregorianCalendarObjectpublic CalendarValue toCalendarValue()
Copyright (c) 2004-2018 Saxonica Limited. All rights reserved.