Representation for W3C XML Schema 1.0 date/time datatypes.
Specifically, these date/time datatypes are
dateTime,
time,
date,
gYearMonth,
gMonthDay,
gYear,
gMonth and
gDay
defined in the XML Namespace
"http://www.w3.org/2001/XMLSchema".
These datatypes are normatively defined in
W3C XML Schema 1.0 Part 2, Section 3.2.7-14.
The table below defines the mapping between XML Schema 1.0 date/time datatype fields and this class' fields. It also summarizes the value constraints for the date and time fields defined in W3C XML Schema 1.0 Part 2, Appendix D, ISO 8601 Date and Time Formats.
| Date/time datatype field mapping between XML Schema 1.0 and Java representation | ||
|---|---|---|
| XML Schema 1.0 datatype field |
Related XMLGregorianCalendar Accessor(s) |
Value Range |
| year | getYear() + getEon() orgetEonAndYear
|
getYear() is a value between -(10^9-1) to (10^9)-1
or DatatypeConstants#FIELD_UNDEFINED.getEon() is high order year value in billion of years.getEon() has values greater than or equal to (10^9) or less than or equal to -(10^9).
A value of null indicates field is undefined.
Given that XML Schema 1.0 errata states that the year zero
will be a valid lexical value in a future version of XML Schema,
this class allows the year field to be set to zero. Otherwise,
the year field value is handled exactly as described
in the errata and [ISO-8601-1988]. Note that W3C XML Schema 1.0
validation does not allow for the year field to have a value of zero.
|
| month | getMonth() |
1 to 12 or DatatypeConstants#FIELD_UNDEFINED |
| day | getDay() |
Independent of month, max range is 1 to 31 or DatatypeConstants#FIELD_UNDEFINED.The normative value constraint stated relative to month field's value is in W3C XML Schema 1.0 Part 2, Appendix D. |
| hour | getHour() |
0 to 24 or DatatypeConstants#FIELD_UNDEFINED
For a value of 24, the minute and second field must be zero.
|
| minute | getMinute() |
0 to 59 or DatatypeConstants#FIELD_UNDEFINED |
| second |
getSecond() + getMillisecond()/1000 orgetSecond() + getFractionalSecond()
|
getSecond() from 0 to 60 or DatatypeConstants#FIELD_UNDEFINED.(Note: 60 only allowable for leap second.) getFractionalSecond() allows for infinite precision over the range from 0.0 to 1.0 when
the getSecond() is defined.FractionalSecond is optional and has a value of null when it is undefined.getMillisecond() is the convenience
millisecond precision of value of getFractionalSecond().
|
| timezone | getTimezone() |
Number of minutes or DatatypeConstants#FIELD_UNDEFINED.
Value range from -14 hours (-14 * 60 minutes) to 14 hours (14 * 60 minutes).
|
All maximum value space constraints listed for the fields in the table
above are checked by factory methods, setter methods and parse methods of
this class. IllegalArgumentException is thrown when
parameter's value is outside the maximum value constraint for the field.
Validation checks, for example, whether days in month should be
limited to 29, 30 or 31 days, that are dependent on the values of other
fields are not checked by these methods.
The following operations are defined for this class:
java.util.GregorianCalendarcompare(XMLGregorianCalendar)equals(Object) defined relative to compare(XMLGregorianCalendar).javax.xml.datatype.Duration .
instance as defined in
W3C XML Schema 1.0 Part 2, Appendix E, Adding durations to dateTimes.javax.xml.datatype.Duration
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private static final BigInteger | BILLION_B
BigInteger constant; representing a billion. |
| private static final int | BILLION_I
int constant; representing a billion. |
| private int | day
Day of this |
| private static final int | DAY
Day index for MIN_ and MAX_FIELD_VALUES. |
| private static final BigDecimal | |
| private static final BigDecimal | |
| private static final BigDecimal | |
| private BigInteger | eon
Eon of this |
| private static final String[] | FIELD_NAME
field names indexed by YEAR..TIMEZONE. |
| private static final BigInteger | |
| private static final BigInteger | |
| private BigDecimal | fractionalSecond
Fractional second of this |
| private int | hour
Hour of this |
| private static final int | HOUR
Hour index for MIN_ and MAX_FIELD_VALUES. |
| private static final BigInteger | |
| public static final XMLGregorianCalendar | LEAP_YEAR_DEFAULT
Use as a template for default field values when
converting to a |
| private static final int[] | MAX_FIELD_VALUE
Maximum field values indexed by YEAR..TIMEZONE. |
| private static final int | MILLISECOND
Second index for MIN_ and MAX_FIELD_VALUES. |
| private static final int[] | MIN_FIELD_VALUE
Minimum field values indexed by YEAR..TIMEZONE. |
| private int | minute
Minute of this |
| private static final int | MINUTE
Minute index for MIN_ and MAX_FIELD_VALUES. |
| private int | month
Month of this |
| private static final int | MONTH
Month index for MIN_ and MAX_FIELD_VALUES. |
| private int | |
| private BigInteger | orig_eon
Backup values |
| private BigDecimal | |
| private int | |
| private int | |
| private int | |
| private int | |
| private int | |
| private int | |
| private static final Date | PURE_GREGORIAN_CHANGE
Obtain a pure Gregorian Calendar by calling GregorianCalendar.setChange(PURE_GREGORIAN_CHANGE). |
| private int | second
Second of this |
| private static final int | SECOND
Second index for MIN_ and MAX_FIELD_VALUES. |
| private static final long | serialVersionUID
Stream Unique Identifier. |
| private static final BigInteger | |
| private int | timezone
Timezone of this |
| private static final int | TIMEZONE
Timezone index for MIN_ and MAX_FIELD_VALUES |
| private static final BigInteger | |
| private static final BigInteger | |
| private int | year
Year of this |
| private static final int | YEAR
Year index for MIN_ and MAX_FIELD_VALUES. |
| Access | Constructor and Description |
|---|---|
| protected | XMLGregorianCalendarImpl(String
Lexical representation of one the eight
XML Schema date/time datatypes. lexicalRepresentation)Constructs a new XMLGregorianCalendar object. |
| public | XMLGregorianCalendarImpl()
Create an instance with all date/time datatype fields set to
|
| protected | XMLGregorianCalendarImpl(BigInteger
of year, int XMLGregorianCalendar to be created.of month, int XMLGregorianCalendar to be created.of day, int XMLGregorianCalendar to be created.of hour, int XMLGregorianCalendar to be created.of minute, int XMLGregorianCalendar to be created.of second, BigDecimal XMLGregorianCalendar to be created.of fractionalSecond, int XMLGregorianCalendar to be created.of timezone)XMLGregorianCalendar to be created.Private constructor allowing for complete value spaces allowed by W3C XML Schema 1.0 recommendation for xsd:dateTime and related builtin datatypes. |
| private | XMLGregorianCalendarImpl(int
of year, int XMLGregorianCalendar to be created.of month, int XMLGregorianCalendar to be created.of day, int XMLGregorianCalendar to be created.of hour, int XMLGregorianCalendar to be created.of minute, int XMLGregorianCalendar to be created.of second, int XMLGregorianCalendar to be created.of millisecond, int XMLGregorianCalendar to be created.of timezone)XMLGregorianCalendar to be created.Private constructor of value spaces that a
|
| public | XMLGregorianCalendarImpl(GregorianCalendar
java.util.GregorianCalendar used to create XMLGregorianCalendarConvert a |
| Modifier and Type | Method and Description |
|---|---|
| public void | add(Duration
Duration to add to this duration)XMLGregorianCalendar.Implements abstract javax. Add |
| private void | |
| public void | clear()
Implements abstract javax. Unset all fields to undefined. |
| public Object | Returns: copy of thisObjectImplements abstract javax. Creates and returns a copy of this object. |
| public int | Returns: the relationship betweenlhs and rhs as
DatatypeConstants#LESSER,
DatatypeConstants#EQUAL,
DatatypeConstants#GREATER or
DatatypeConstants#INDETERMINATE.instance of rhs)XMLGregorianCalendar to compareImplements abstract javax. 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. |
| private static int | compareField(int Pfield, int Qfield)
Implement Step B from http://www.w3.org/TR/xmlschema-2/#dateTime-order. |
| private static int | |
| private static int | |
| public static XMLGregorianCalendar | Returns: XMLGregorianCalendar created from parameter values.of year, int XMLGregorianCalendar to be created.of month, int XMLGregorianCalendar to be created.of day, int XMLGregorianCalendar to be created.offset in minutes. timezone)DatatypeConstants#FIELD_UNDEFINED indicates optional field is not set.Create a Java representation of XML Schema builtin datatype |
| public static XMLGregorianCalendar | Returns: XMLGregorianCalendar created from parameter values.represents both high-order eons and low-order year. year, int of month, int dateTimeof day, int dateTimeof hours, int dateTimeof minutes, int dateTimeof seconds, BigDecimal dateTimevalue of null indicates optional field is absent. fractionalSecond, int offset in minutes. timezone)DatatypeConstants#FIELD_UNDEFINED indicates optional field is not set.Create a Java representation of XML Schema builtin datatype |
| public static XMLGregorianCalendar | Returns: XMLGregorianCalendar created from parameter values.represents both high-order eons and low-order year. year, int of month, int dateTimeof day, int dateTimeof hour, int dateTimeof minute, int dateTimeof second)dateTimeCreate a Java instance of XML Schema builtin datatype dateTime. |
| public static XMLGregorianCalendar | Returns: XMLGregorianCalendar created from parameter values.represents low-order year. year, int of month, int dateTimeof day, int dateTimeof hours, int dateTimeof minutes, int dateTimeof seconds, int dateTimeof milliseconds, int dateTime. DatatypeConstants#FIELD_UNDEFINED indicates optional field is not set.offset in minutes. timezone)DatatypeConstants#FIELD_UNDEFINED indicates optional field is not set.Create a Java representation of XML Schema builtin datatype |
| public static XMLGregorianCalendar | Returns: XMLGregorianCalendar created from parameter values.number of hours hours, int number of minutes minutes, int number of seconds seconds, int offset in minutes. timezone)DatatypeConstants#FIELD_UNDEFINED indicates optional field is not set.Create a Java instance of XML Schema builtin datatype |
| public static XMLGregorianCalendar | Returns: XMLGregorianCalendar created from parameter values.number of hours hours, int number of minutes minutes, int number of seconds seconds, BigDecimal value of fractionalSecond, int null indicates that this optional field is not set.offset in minutes. timezone)DatatypeConstants#FIELD_UNDEFINED indicates optional field is not set.Create a Java instance of XML Schema builtin datatype time. |
| public static XMLGregorianCalendar | Returns: XMLGregorianCalendar created from parameter values.number of hours hours, int number of minutes minutes, int number of seconds seconds, int number of milliseconds milliseconds, int offset in minutes. timezone)DatatypeConstants#FIELD_UNDEFINED indicates optional field is not set.Create a Java instance of XML Schema builtin datatype time. |
| public boolean | Returns: true when compare(this,(XMLGregorianCalendar)obj) == EQUAL..to compare. obj)Overrides javax. Indicates whether parameter |
| private String | |
| public int | getDay()
Implements abstract javax. DatatypeConstants#FIELD_UNDEFINED.
|
| public BigInteger | Returns: eon of thisXMLGregorianCalendar. The value
returned is an integer multiple of 10^9.Implements abstract javax. Return high order component for XML Schema 1.0 dateTime datatype field for
|
| public BigInteger | Returns: sum ofeon and BigInteger.valueOf(year)
when both fields are defined. When only year is defined,
return it. When both eon and year are not
defined, return null.Implements abstract javax. Return XML Schema 1.0 dateTime datatype field for
|
| public BigDecimal | Returns: fractional seconds of thisXMLGregorianCalendar.Implements abstract javax. Return fractional seconds. |
| public int | getHour()
Implements abstract javax. DatatypeConstants#FIELD_UNDEFINED.
|
| public int | Returns: Millisecond of thisXMLGregorianCalendar.Overrides javax. Return millisecond precision of |
| public int | getMinute()
Implements abstract javax. DatatypeConstants#FIELD_UNDEFINED.
|
| public int | Returns: year of thisXMLGregorianCalendar.Implements abstract javax. Return number of month or |
| public int | Returns: Second of thisXMLGregorianCalendar.Implements abstract javax. Return seconds or |
| private BigDecimal | |
| public int | getTimezone()
Implements abstract javax. DatatypeConstants#FIELD_UNDEFINED if this optional field is not defined.
|
| public TimeZone | Returns: TimeZone for this.default zoneoffset if this zoneoffset is
defaultZoneoffset)DatatypeConstants#FIELD_UNDEFINED.Implements abstract javax. Returns a |
| public QName | Returns: One of the following class constants:DatatypeConstants#DATETIME,
DatatypeConstants#TIME,
DatatypeConstants#DATE,
DatatypeConstants#GYEARMONTH,
DatatypeConstants#GMONTHDAY,
DatatypeConstants#GYEAR,
DatatypeConstants#GMONTH or
DatatypeConstants#GDAY.Implements abstract javax. Return the name of the XML Schema date/time type that this instance maps to. |
| public int | Returns: year of thisXMLGregorianCalendar.Implements abstract javax. Return low order component for XML Schema 1.0 dateTime datatype field for
|
| public int | Returns: hash code of this object.Overrides javax. Returns a hash code consistent with the definition of the equals method. |
| private static int | Returns: result of comparing P and Q, value ofDatatypeConstants#EQUAL,
DatatypeConstants#LESSER,
DatatypeConstants#GREATER or
DatatypeConstants#INDETERMINATE.calendar instance with normalized timezone offset or
having same timezone as Q P, XMLGregorianCalendar calendar instance with normalized timezone offset or
having same timezone as P Q)Implements Step B from http://www.w3.org/TR/xmlschema-2/#dateTime-order |
| private static boolean | |
| public boolean | Returns: true if data values are valid.Implements abstract javax. getXMLSchemaType() constraints.
|
| private static int | |
| private static int | |
| public XMLGregorianCalendar | normalize()
Implements abstract javax. Normalize this instance to UTC. |
| private XMLGregorianCalendar | |
| public static XMLGregorianCalendar | Returns: XMLGregorianCalendar created from parsing lexicalRepresentation parameter.Lexical representation of one the 8 XML Schema calendar datatypes. lexicalRepresentation)Constructs a new XMLGregorianCalendar object by parsing its lexical string representation as defined in XML Schema 1.0 Part 2, Section 3.2.[7-14].1, Lexical Representation. The string representation may not have any leading and trailing whitespaces. |
| private void | printNumber(StringBuffer
The formatted string will be appended into this buffer. out, int The integer to be printed. number, int The field will be printed by using at least this
number of digits. For example, 5 will be printed as "0005"
if nDigits==4. nDigits)Prints an integer as a String. |
| private void | printNumber(StringBuffer
The formatted string will be appended into this buffer. out, BigInteger The integer to be printed. number, int The field will be printed by using at least this
number of digits. For example, 5 will be printed as "0005"
if nDigits==4. nDigits)Prints an BigInteger as a String. |
| public void | reset()
Implements abstract javax.
|
| pack-priv static BigInteger | Returns: non-nullBigInteger.Compute |
| private void | |
| public void | setDay(int
value constraints summarized in day field of date/time field mapping table. day)Implements abstract javax. Set days in month. |
| private void | setEon(BigInteger
value constraints summarized in year field of date/time field mapping table. eon)Set high order part of XSD |
| public void | setFractionalSecond(BigDecimal
value constraints summarized in
second field of date/time field mapping table. fractional)Implements abstract javax. |
| public void | setHour(int
value constraints summarized in hour field of date/time field mapping table. hour)Implements abstract javax. |
| public void | setMillisecond(int
value constraints summarized in
second field of date/time field mapping table. millisecond)Implements abstract javax. |
| public void | setMinute(int
value constraints summarized in minute field of date/time field mapping table. minute)Implements abstract javax. |
| public void | setMonth(int
value constraints summarized in month field of date/time field mapping table. month)Implements abstract javax. Set month. |
| public void | setSecond(int
value constraints summarized in second field of date/time field mapping table. second)Implements abstract javax. |
| public void | setTime(int
value constraints are summarized in
hour field of date/time field mapping table. hour, int value constraints are summarized in
minute field of date/time field mapping table. minute, int value constraints are summarized in
second field of date/time field mapping table. second)Overrides javax. Set time as one unit. |
| public void | setTime(int
value constraints are summarized in
hour field of date/time field mapping table. hour, int value constraints are summarized in
minute field of date/time field mapping table. minute, int value constraints are summarized in
second field of date/time field mapping table. second, BigDecimal value of fractional)null indicates this optional
field is not set.Overrides javax. Set time as one unit, including the optional infinite precison fractional seconds. |
| public void | setTime(int
value constraints are summarized in
hour field of date/time field mapping table. hour, int value constraints are summarized in
minute field of date/time field mapping table. minute, int value constraints are summarized in
second field of date/time field mapping table. second, int value of millisecond)DatatypeConstants#FIELD_UNDEFINED indicates this
optional field is not set.Overrides javax. Set time as one unit, including optional milliseconds. |
| public void | setTimezone(int
value constraints summarized in
timezone field of date/time field mapping table. offset)Implements abstract javax. Set the number of minutes in the timezone offset. |
| public void | setYear(BigInteger
value constraints summarized in year field of date/time field mapping table. year)Implements abstract javax. Set low and high order component of XSD |
| public void | setYear(int
value constraints are summarized in year field of date/time field mapping table.
If year is year)DatatypeConstants#FIELD_UNDEFINED, then eon is set to null.Implements abstract javax. Set year of XSD |
| public GregorianCalendar | toGregorianCalendar()
Implements abstract javax. Convert |
| public GregorianCalendar | Returns: a java.util.GregorianCalendar conversion of this instance.provide Timezone. timezone, Locale null is a legal value.provide explicit Locale. Use default GregorianCalendar locale if
value is aLocale, XMLGregorianCalendar null.provide default field values to use when corresponding
field for this instance is DatatypeConstants.FIELD_UNDEFINED or null.
If defaults)defaultsis null or a field
within the specified defaults is undefined,
just use java.util.GregorianCalendar defaults.Implements abstract javax. Convert |
| private String | Returns: String representation of BigDecimalBigDecimal to format as a StringTurns |
| public String | Returns: XML, asString, representation of this XMLGregorianCalendarImplements abstract javax. Return the lexical representation of |
| private Object | Returns: An object that encapsulates the string returned bythis.toXMLFormat().Writes |