java.lang.Objectjavax.xml.datatype.XMLGregorianCalendar
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 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. |
| month | getMonth() |
1 to 12 or FIELD_UNDEFINED |
| day | getDay() |
Independent of month, max range is 1 to 31 or 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 23 or FIELD_UNDEFINED
|
| minute | getMinute() |
0 to 59 or FIELD_UNDEFINED |
| second | getSecond() + getMillisecond()/1000 orgetSecond() + getFractionalSecond() |
getSecond() from 0 to 60 or FIELD_UNDEFINED.(Note: 60 only allowable for leap second.) getMillisecond() allows only for millisecond precision,
is optional and has a value of FIELD_UNDEFINED when
it is undefined.getFractionalSecond() allows for infinite precision over
the range from 0.0 to 1.0.FractionalSecond is optional and has a value of null when it is undefined. |
| timezone | getTimezone() |
Number of minutes or FIELD_UNDEFINED.
Value range from -14 hours (-14 * 60 minutes) to 14 hours (14 * 60 minutes) exclusive.
|
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, XMLGregorianCalendar)equals(Object) defined relative to compare(XMLGregorianCalendar, XMLGregorianCalendar).Duration.
instance as defined in
W3C XML Schema 1.0 Part 2, Appendix E, Adding durations to dateTimes.
Duration,
Serialized Form| Field Summary | |
|---|---|
static int |
APRIL
Value for fourth month of year. |
static int |
AUGUST
Value for eighth month of year. |
static QName |
DATE
Fully qualified name for W3C XML Schema 1.0 datatype date. |
static QName |
DATETIME
Fully qualified name for W3C XML Schema 1.0 datatype dateTime. |
static int |
DECEMBER
Value for twelve month of year. |
static int |
EQUAL
Partial order relation comparison result. |
static int |
FEBRUARY
Value for second month of year. |
static int |
FIELD_UNDEFINED
Designation that an "int" field is not set. |
static QName |
GDAY
Fully qualified name for W3C XML Schema 1.0 datatype gDay. |
static QName |
GMONTH
Fully qualified name for W3C XML Schema 1.0 datatype gMonth. |
static QName |
GMONTHDAY
Fully qualified name for W3C XML Schema 1.0 datatype gMonthDay. |
static int |
GREATER
Partial order relation comparison result. |
static QName |
GYEAR
Fully qualified name for W3C XML Schema 1.0 datatype gYear. |
static QName |
GYEARMONTH
Fully qualified name for W3C XML Schema 1.0 datatype gYearMonth. |
static int |
INDETERMINATE
Partial order relation comparison result. |
static int |
JANUARY
Value for first month of year. |
static int |
JULY
Value for seventh month of year. |
static int |
JUNE
Value for sixth month of year. |
static XMLGregorianCalendar |
LEAP_YEAR_DEFAULT
Use as a template for default field values when converting to a java.util.GregorianCalendar, set to a leap
year date of January 1, 0400 at midnight. |
static int |
LESSER
Partial order relation comparison result. |
static int |
MARCH
Value for third month of year. |
static int |
MAX_TIMEZONE_OFFSET
W3C XML Schema max timezone offset is -14:00. |
static int |
MAY
Value for fifth month of year. |
static int |
MIN_TIMEZONE_OFFSET
W3C XML Schema min timezone offset is +14:00. |
static int |
NOVEMBER
Value for eleven month of year. |
static int |
OCTOBER
Value for tenth month of year. |
static int |
SEPTEMBER
Value for ninth month of year. |
static QName |
TIME
Fully qualified name for W3C XML Schema 1.0 datatype time. |
| Constructor Summary | |
|---|---|
XMLGregorianCalendar()
Create an instance with all date/time datatype fields set to FIELD_UNDEFINED or null respectively. |
|
| Method Summary | |
|---|---|
void |
add(Duration duration)
Add duration to this instance.<\p> |
void |
clear()
Unset all fields to undefined. |
Object |
clone()
Creates and returns a copy of this object. |
static int |
compare(XMLGregorianCalendar lhs,
XMLGregorianCalendar rhs)
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. |
static XMLGregorianCalendar |
createDate(int year,
int month,
int day,
int timezone)
Create a Java representation of XML Schema builtin datatype date or g*. |
static XMLGregorianCalendar |
createDateTime(BigInteger year,
int month,
int day,
int hours,
int minutes,
int seconds,
BigDecimal fractionalSecond,
int timezone)
Create a Java representation of XML Schema builtin datatype dateTime. |
static XMLGregorianCalendar |
createDateTime(int year,
int month,
int day,
int hour,
int minute,
int second)
Create a Java instance of XML Schema builtin datatype dateTime. |
static XMLGregorianCalendar |
createDateTime(int year,
int month,
int day,
int hours,
int minutes,
int seconds,
int milliseconds,
int timezone)
Create a Java representation of XML Schema builtin datatype dateTime. |
static XMLGregorianCalendar |
createTime(int hours,
int minutes,
int seconds,
BigDecimal fractionalSecond,
int timezone)
Create a Java instance of XML Schema builtin datatype time. |
static XMLGregorianCalendar |
createTime(int hours,
int minutes,
int seconds,
int timezone)
Create a Java instance of XML Schema builtin datatype time. |
static XMLGregorianCalendar |
createTime(int hours,
int minutes,
int seconds,
int milliseconds,
int timezone)
Create a Java instance of XML Schema builtin datatype time. |
boolean |
equals(Object obj)
Indicates whether parameter obj is "equal to" this one. |
static XMLGregorianCalendar |
fromGregorianCalendar(GregorianCalendar cal)
Convert a java.util.GregorianCalendar to XML Schema 1.0
representation. |
int |
getDay()
Return day in month or FIELD_UNDEFINED. |
BigInteger |
getEon()
Get the eons of the year. |
BigInteger |
getEonAndYear()
Return XML Schema 1.0 dateTime datatype field for year. |
BigDecimal |
getFractionalSecond()
Return fractional seconds. |
int |
getHour()
Return hours or FIELD_UNDEFINED. |
int |
getMillisecond()
Return milliseconds or FIELD_UNDEFINED.<\p> |
int |
getMinute()
Return minutes or FIELD_UNDEFINED.<\p>
Returns FIELD_UNDEFINED if this field is not defined. |
int |
getMonth()
Return number of month or FIELD_UNDEFINED. |
int |
getSecond()
Return seconds or FIELD_UNDEFINED.<\p> |
int |
getTimezone()
Return timezone offset in minutes or FIELD_UNDEFINED if this optional field is not defined. |
QName |
getXMLSchemaType()
Return the name of the XML Schema date/time type that this instance maps to. |
int |
getYear()
Return low order component XML Schema 1.0 dataTime datatype field for year or FIELD_UNDEFINED. |
int |
hashCode()
Returns a hash code consistent with the definition of the equals method. |
boolean |
isValid()
Validate instance by getXMLSchemaType() constraints. |
static XMLGregorianCalendar |
parse(String 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. |
void |
setDay(int day)
Set days in month. |
void |
setMonth(int month)
Set month. |
void |
setTime(int hour,
int minute,
int second)
Set time as one unit. |
void |
setTime(int hour,
int minute,
int second,
BigDecimal fractional)
Set time as one unit, including the optional infinite precison fractional seconds. |
void |
setTime(int hour,
int minute,
int second,
int millisecond)
Set time as one unit, including optional milliseconds. |
void |
setTimezone(int offset)
Set the number of minutes in the timezone offset. |
void |
setYear(BigInteger year)
Set low and high order component of XSD dateTime year field. |
void |
setYear(int year)
Set year of XSD dateTime year field. |
GregorianCalendar |
toGregorianCalendar()
Convert this to java.util.GregorianCalendar. |
GregorianCalendar |
toGregorianCalendar(TimeZone timezone,
Locale aLocale,
XMLGregorianCalendar defaults)
Convert this along with provided parameters
to java.util.GregorianCalendar instance. |
String |
toXMLFormat()
Return the lexical representation of this instance. |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int JANUARY
getMonth(),
setMonth(int),
Constant Field Valuespublic static final int FEBRUARY
getMonth(),
setMonth(int),
Constant Field Valuespublic static final int MARCH
getMonth(),
setMonth(int),
Constant Field Valuespublic static final int APRIL
getMonth(),
setMonth(int),
Constant Field Valuespublic static final int MAY
getMonth(),
setMonth(int),
Constant Field Valuespublic static final int JUNE
getMonth(),
setMonth(int),
Constant Field Valuespublic static final int JULY
getMonth(),
setMonth(int),
Constant Field Valuespublic static final int AUGUST
getMonth(),
setMonth(int),
Constant Field Valuespublic static final int SEPTEMBER
getMonth(),
setMonth(int),
Constant Field Valuespublic static final int OCTOBER
getMonth(),
setMonth(int),
Constant Field Valuespublic static final int NOVEMBER
getMonth(),
setMonth(int),
Constant Field Valuespublic static final int DECEMBER
getMonth(),
setMonth(int),
Constant Field Valuespublic static final int FIELD_UNDEFINED
public static final int LESSER
compare(XMLGregorianCalendar, XMLGregorianCalendar),
Constant Field Valuespublic static final int EQUAL
compare(XMLGregorianCalendar, XMLGregorianCalendar),
Constant Field Valuespublic static final int GREATER
compare(XMLGregorianCalendar, XMLGregorianCalendar),
Constant Field Valuespublic static final int INDETERMINATE
compare(XMLGregorianCalendar, XMLGregorianCalendar),
Constant Field Valuespublic static final XMLGregorianCalendar LEAP_YEAR_DEFAULT
Use as a template for default field values when
converting to a java.util.GregorianCalendar, set to a leap
year date of January 1, 0400 at midnight.
toGregorianCalendar(TimeZone, Locale, XMLGregorianCalendar)public static final QName DATETIME
Fully qualified name for W3C XML Schema 1.0 datatype dateTime.
public static final QName TIME
Fully qualified name for W3C XML Schema 1.0 datatype time.
public static final QName DATE
Fully qualified name for W3C XML Schema 1.0 datatype date.
public static final QName GYEARMONTH
Fully qualified name for W3C XML Schema 1.0 datatype gYearMonth.
public static final QName GMONTHDAY
Fully qualified name for W3C XML Schema 1.0 datatype gMonthDay.
public static final QName GYEAR
Fully qualified name for W3C XML Schema 1.0 datatype gYear.
public static final QName GMONTH
Fully qualified name for W3C XML Schema 1.0 datatype gMonth.
public static final QName GDAY
Fully qualified name for W3C XML Schema 1.0 datatype gDay.
public static final int MAX_TIMEZONE_OFFSET
public static final int MIN_TIMEZONE_OFFSET
| Constructor Detail |
|---|
public XMLGregorianCalendar()
Create an instance with all date/time datatype fields set to
FIELD_UNDEFINED or null respectively.
| Method Detail |
|---|
public static XMLGregorianCalendar createDateTime(BigInteger year,
int month,
int day,
int hours,
int minutes,
int seconds,
BigDecimal fractionalSecond,
int timezone)
Create a Java representation of XML Schema builtin datatype dateTime.
All possible fields are specified for this factory method.
year - represents both high-order eons and low-order year.month - of dateTimeday - of dateTimehours - of dateTimeminutes - of dateTimeseconds - of dateTimefractionalSecond - value of null indicates optional field is absent.timezone - offset in minutes. FIELD_UNDEFINED indicates optional field is not set.
XMLGregorianCalendar created from parameter values.
IllegalArgumentException - if any parameter is outside value
constraints for the field as specified in
date/time field mapping table.FIELD_UNDEFINED
public static XMLGregorianCalendar createDateTime(int year,
int month,
int day,
int hour,
int minute,
int second)
Create a Java instance of XML Schema builtin datatype dateTime.
year - represents both high-order eons and low-order year.month - of dateTimeday - of dateTimehour - of dateTimeminute - of dateTimesecond - of dateTime
XMLGregorianCalendar created from parameter values.
IllegalArgumentException - if any parameter is outside value constraints for the field as specified in
date/time field mapping table.FIELD_UNDEFINED
public static XMLGregorianCalendar createDateTime(int year,
int month,
int day,
int hours,
int minutes,
int seconds,
int milliseconds,
int timezone)
Create a Java representation of XML Schema builtin datatype dateTime.
All possible fields are specified for this factory method.
year - represents low-order year.month - of dateTimeday - of dateTimehours - of dateTimeminutes - of dateTimeseconds - of dateTimemilliseconds - of dateTime. FIELD_UNDEFINED indicates optional field is not set.timezone - offset in minutes. FIELD_UNDEFINED indicates optional field is not set.
XMLGregorianCalendar created from parameter values.
IllegalArgumentException - if any parameter is outside value constraints for the field as specified in
date/time field mapping table.FIELD_UNDEFINED
public static XMLGregorianCalendar createDate(int year,
int month,
int day,
int timezone)
Create a Java representation of XML Schema builtin datatype date or g*.
For example, an instance of gYear can be created invoking this factory
with month and day parameters set to
FIELD_UNDEFINED.
year - of XMLGregorianCalendar to be created.month - of XMLGregorianCalendar to be created.day - of XMLGregorianCalendar to be created.timezone - offset in minutes. FIELD_UNDEFINED indicates optional field is not set.
XMLGregorianCalendar created from parameter values.
IllegalArgumentException - if any parameter is outside value
constraints for the field as specified in
date/time field mapping table.FIELD_UNDEFINED
public static XMLGregorianCalendar createTime(int hours,
int minutes,
int seconds,
int timezone)
time.
hours - number of hoursminutes - number of minutesseconds - number of secondstimezone - offset in minutes. FIELD_UNDEFINED indicates optional field is not set.
XMLGregorianCalendar created from parameter values.
IllegalArgumentException - if any parameter is outside value
constraints for the field as specified in
date/time field mapping table.FIELD_UNDEFINED
public static XMLGregorianCalendar createTime(int hours,
int minutes,
int seconds,
BigDecimal fractionalSecond,
int timezone)
Create a Java instance of XML Schema builtin datatype time.
hours - number of hoursminutes - number of minutesseconds - number of secondsfractionalSecond - value of null indicates that this optional field is not set.timezone - offset in minutes. FIELD_UNDEFINED indicates optional field is not set.
XMLGregorianCalendar created from parameter values.
IllegalArgumentException - if any parameter is outside value
constraints for the field as specified in
date/time field mapping table.FIELD_UNDEFINED
public static XMLGregorianCalendar createTime(int hours,
int minutes,
int seconds,
int milliseconds,
int timezone)
Create a Java instance of XML Schema builtin datatype time.
hours - number of hoursminutes - number of minutesseconds - number of secondsmilliseconds - number of millisecondstimezone - offset in minutes. FIELD_UNDEFINED indicates optional field is not set.
XMLGregorianCalendar created from parameter values.
IllegalArgumentException - if any parameter is outside value
constraints for the field as specified in
date/time field mapping table.FIELD_UNDEFINEDpublic BigInteger getEon()
Get the eons of the 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.
XMLGregorianCalendar.getYear(),
getEonAndYear()public int getYear()
Return low order component XML Schema 1.0 dataTime datatype field for
year or FIELD_UNDEFINED.
Value constraints for this value are summarized in year field of date/time field mapping table.
XMLGregorianCalendar.getEon(),
getEonAndYear()public 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.
eon 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.getEon(),
getYear()public int getMonth()
Return number of month or FIELD_UNDEFINED.
Value constraints for this value are summarized in month field of date/time field mapping table.
XMLGregorianCalendar.public int getDay()
FIELD_UNDEFINED.
Value constraints for this value are summarized in day field of date/time field mapping table.
setDay(int)public int getTimezone()
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.
setTimezone(int)public int getHour()
FIELD_UNDEFINED.
Returns FIELD_UNDEFINED if this field is not defined.
Value constraints for this value are summarized in hour field of date/time field mapping table.
setTime(int, int, int)public int getMinute()
FIELD_UNDEFINED.<\p>
Returns FIELD_UNDEFINED if this field is not defined.
Value constraints for this value are summarized in minute field of date/time field mapping table.
setTime(int, int, int)public int getSecond()
Return seconds or FIELD_UNDEFINED.<\p>
Returns FIELD_UNDEFINED if this field is not defined.
Value constraints for this value are summarized in second field of date/time field mapping table.
XMLGregorianCalendar.getFractionalSecond(),
setTime(int, int, int)public int getMillisecond()
Return milliseconds or FIELD_UNDEFINED.<\p>
Returns FIELD_UNDEFINED if this field is not defined.<\p>
Value constraints for this value are summarized in second field of date/time field mapping table.
XMLGregorianCalendar.getFractionalSecond(),
setTime(int, int, int)public 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.
XMLGregorianCalendar.getSecond(),
setTime(int, int, int, BigDecimal)public void setYear(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.
year - value constraints summarized in year field of date/time field mapping table.
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
FIELD_UNDEFINED.
year - value constraints are summarized in year field of date/time field mapping table.
If year is 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 FIELD_UNDEFINED.
month - value constraints summarized in month field of date/time field mapping table.
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 FIELD_UNDEFINED.
day - value constraints summarized in day field of date/time field mapping table.
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 FIELD_UNDEFINED.
offset - value constraints summarized in
timezone field of date/time field mapping table.
IllegalArgumentException - if offset parameter is
outside value constraints for the field as specified in
date/time field mapping table.
public void setTime(int hour,
int minute,
int second)
Set time as one unit.
hour - value constraints are summarized in
hour field of date/time field mapping table.minute - value constraints are summarized in
minute field of date/time field mapping table.second - value constraints are summarized in
second field of date/time field mapping table.
IllegalArgumentException - if any parameter is
outside value constraints for the field as specified in
date/time field mapping table.setTime(int, int, int, BigDecimal)
public void setTime(int hour,
int minute,
int second,
BigDecimal fractional)
Set time as one unit, including the optional infinite precison fractional seconds.
hour - value constraints are summarized in
hour field of date/time field mapping table.minute - value constraints are summarized in
minute field of date/time field mapping table.second - value constraints are summarized in
second field of date/time field mapping table.fractional - value of null indicates this optional
field is not set.
IllegalArgumentException - if any parameter is
outside value constraints for the field as specified in
date/time field mapping table.
public void setTime(int hour,
int minute,
int second,
int millisecond)
Set time as one unit, including optional milliseconds.
hour - value constraints are summarized in
hour field of date/time field mapping table.minute - value constraints are summarized in
minute field of date/time field mapping table.second - value constraints are summarized in
second field of date/time field mapping table.millisecond - value of FIELD_UNDEFINED indicates this
optional field is not set.
IllegalArgumentException - if any parameter is
outside value constraints for the field as specified in
date/time field mapping table.
public static int compare(XMLGregorianCalendar lhs,
XMLGregorianCalendar rhs)
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.
lhs - instance of XMLGregorianCalendar to comparerhs - instance of XMLGregorianCalendar to compare
lhs and rhs as LESSER, EQUAL, GREATER or
INDETERMINATE.
NullPointerException - if lhs or rhs
parameters are null.public boolean equals(Object obj)
Indicates whether parameter obj is "equal to" this one.
equals in class Objectobj - to compare.
true when compare(this,(XMLGregorianCalendar)obj) == EQUAL..Object.hashCode(),
Hashtablepublic int hashCode()
Returns a hash code consistent with the definition of the equals method.
hashCode in class ObjectObject.equals(java.lang.Object),
Hashtablepublic static XMLGregorianCalendar parse(String 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.
The parsing is done field by field so that the following holds for any lexically correct string x:
new XMLGregorianCalendar(x).toXMLFormat().equals(x)
Returns a non-null valid XMLGregorianCalendar object that holds the value indicated by the lexicalRepresentation parameter.
lexicalRepresentation - Lexical representation of one the 8 XML Schema calendar datatypes.
XMLGregorianCalendar created from parsing lexicalRepresentation parameter.
IllegalArgumentException - If the given string does not conform to the aforementioned
specification.
NullPointerException - If the given string is null.public 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().
String, representation of this XMLGregorianCalendar
IllegalStateException - if the combination of set fields
does not match one of the eight defined XML Schema builtin date/time datatypes.public 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.
|
Required fields for XML Schema 1.0 Date/Time Datatypes. (timezone is optional for all date/time datatypes) |
||||||
|---|---|---|---|---|---|---|
| Datatype | year | month | day | hour | minute | second |
DATETIME |
X | X | X | X | X | X |
DATE |
X | X | X | |||
TIME |
X | X | X | |||
GYEARMONTH |
X | X | ||||
GMONTHDAY |
X | X | ||||
GYEAR |
X | |||||
GMONTH |
X | |||||
GDAY |
X | |||||
DATETIME,
TIME, DATE, GYEARMONTH,
GMONTHDAY, GYEAR, GMONTH or
GDAY.
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.
public void add(Duration duration)
Add duration to this instance.<\p>
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.
duration - Duration to add to this XMLGregorianCalendar.
NullPointerException - when duration parameter is null.
IllegalStateException - when this instance is
XML Schema type TIME or GMONTHDAY since duration
addition is not defined for these two XML Schema builtin datatypes.public GregorianCalendar toGregorianCalendar()
Convert this to java.util.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(TimeZone, Locale, XMLGregorianCalendar).
Field by Field Conversion from this class to
java.util.GregorianCalendar
|
|
|---|---|
java.util.GregorianCalendar field |
javax.xml.datatype.XMLGregorianCalendar field |
ERA |
getEonAndYear().signum() < 0 ? GregorianCalendar.BC : GregorianCalendar.AD |
YEAR |
getEonAndYear().abs().intValue()* |
MONTH |
getMonth() - 1 |
DAY_OF_MONTH |
getDay() |
AM_PM |
getHour() < 12 : Calendar.AM : Calendar.PM |
HOUR_OF_DAY |
getHour() |
MINUTE |
getMinute() |
SECOND |
getSecond() |
MILLISECOND |
get millisecond order from getFractionalSecond()* |
GregorianCalendar.setTimeZone(TimeZone) |
getTimezone() formatted into Custom timezone id |
To ensure consistency in conversion implementations, the new
GregorianCalendar should be instantiated in following
manner.
timeZone value as defined above, create a new
java.util.GregorianCalendar(timeZone,Locale.getDefault()).
GregorianCalendar.setGregorianChange(
new Date(Long.MIN_VALUE)).Calendar.set(int,int)
toGregorianCalendar(java.util.TimeZone, java.util.Locale, XMLGregorianCalendar)
public GregorianCalendar toGregorianCalendar(TimeZone timezone,
Locale aLocale,
XMLGregorianCalendar defaults)
Convert this along with provided parameters
to java.util.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 definedas 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.
GregorianCalendar.setGregorianChange(
new Date(Long.MIN_VALUE)).Calendar.set(int,int)
timezone - 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.
LEAP_YEAR_DEFAULTpublic static XMLGregorianCalendar fromGregorianCalendar(GregorianCalendar cal)
Convert a java.util.GregorianCalendar to XML Schema 1.0
representation.
Field by Field Conversion from
java.util.GregorianCalendar to this class
|
|
|---|---|
javax.xml.datatype.XMLGregorianCalendar field |
java.util.GregorianCalendar field |
setYear(int) |
ERA == GregorianCalendar.BC ? -YEAR : YEAR |
setMonth(int) |
MONTH + 1 |
setDay(int) |
DAY_OF_MONTH |
setTime(int,int,int, BigDecimal) |
HOUR_OF_DAY, MINUTE, SECOND, MILLISECOND |
setTimezone(int)* |
(ZONE_OFFSET + DST_OFFSET) / (60*1000)(in minutes) |
*conversion loss of information. It is not possible to represent
a java.util.GregorianCalendar daylight savings timezone id in the
XML Schema 1.0 date/time datatype representation.
To compute the return value's TimeZone field,
this.getTimezone() != FIELD_UNDEFINED,
create a java.util.TimeZone with a custom timezone id
using the this.getTimezone().GregorianCalendar default timezone value
for the host is defined as specified by
java.util.TimeZone.getDefault().
cal - java.util.GregorianCalendar used to create XMLGregorianCalendar
XMLGregorianCalendar created from java.util.GregorianCalendarpublic Object clone()
Creates and returns a copy of this object.
clone in class ObjectObjectCloneablepublic void clear()
Unset all fields to undefined.
Set all int fields to FIELD_UNDEFINED and reference fields
to null.