public class XMLGregorianCalendarImpl extends XMLGregorianCalendar implements Serializable, Cloneable
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 23 or DatatypeConstants.FIELD_UNDEFINED.
An hour value of 24 is allowed to be set in the lexical space provided the minute and second
field values are zero. However, an hour value of 24 is not allowed in value space and will be
transformed to represent the value of the first instance of the following day as per
XML Schema Part 2: Datatypes Second Edition, 3.2 Primitive datatypes.
|
| 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).Duration.
instance as defined in
W3C XML Schema 1.0 Part 2, Appendix E, Adding durations to dateTimes.Duration,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static XMLGregorianCalendar |
LEAP_YEAR_DEFAULT
Use as a template for default field values when
converting to a
GregorianCalendar, set to a leap
year date of January 1, 0400 at midnight. |
| Modifier | Constructor and Description |
|---|---|
|
XMLGregorianCalendarImpl()
Create an instance with all date/time datatype fields set to
DatatypeConstants.FIELD_UNDEFINED or null respectively. |
protected |
XMLGregorianCalendarImpl(BigInteger year,
int month,
int day,
int hour,
int minute,
int second,
BigDecimal fractionalSecond,
int timezone)
Private constructor allowing for complete value spaces allowed by
W3C XML Schema 1.0 recommendation for xsd:dateTime and related
builtin datatypes.
|
|
XMLGregorianCalendarImpl(GregorianCalendar cal)
Convert a
java.util.GregorianCalendar to XML Schema 1.0
representation. |
protected |
XMLGregorianCalendarImpl(String lexicalRepresentation)
Constructs a new XMLGregorianCalendar object.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(Duration duration)
Add
duration to this instance. |
void |
clear()
Unset all fields to undefined.
|
Object |
clone()
Creates and returns a copy of this object.
|
int |
compare(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. |
int |
getDay()
Return day in month or
DatatypeConstants.FIELD_UNDEFINED. |
BigInteger |
getEon()
Return high order component for XML Schema 1.0 dateTime datatype field for
year. |
BigInteger |
getEonAndYear()
Return XML Schema 1.0 dateTime datatype field for
year. |
BigDecimal |
getFractionalSecond()
Return fractional seconds.
|
int |
getHour()
Return hours or
DatatypeConstants.FIELD_UNDEFINED. |
int |
getMillisecond()
Return millisecond 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. |
TimeZone |
getTimeZone(int defaultZoneoffset)
Returns a
java.util.TimeZone for this class. |
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. |
int |
hashCode()
Returns a hash code consistent with the definition of the equals method.
|
boolean |
isValid()
Validate instance by
getXMLSchemaType() constraints. |
XMLGregorianCalendar |
normalize()
Normalize this instance to UTC.
|
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 |
reset()
reset() is designed to allow the reuse of existing
XMLGregorianCalendars thus saving resources associated
with the creation of new XMLGregorianCalendars. |
void |
setDay(int day)
Set days in month.
|
void |
setFractionalSecond(BigDecimal fractional) |
void |
setHour(int hour) |
void |
setMillisecond(int millisecond) |
void |
setMinute(int minute) |
void |
setMonth(int month)
Set month.
|
void |
setSecond(int second) |
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. |
toStringpublic static final XMLGregorianCalendar LEAP_YEAR_DEFAULT
Use as a template for default field values when
converting to a GregorianCalendar, set to a leap
year date of January 1, 0400 at midnight.
Fields that are optional for an xsd:dateTime instances are defaulted to not being set to any value.
XMLGregorianCalendar fields millisecond, fractional second and timezone return the value indicating
that the field is not set, DatatypeConstants.FIELD_UNDEFINED for millisecond and timezone
and null for fractional second.
protected XMLGregorianCalendarImpl(String lexicalRepresentation) throws IllegalArgumentException
parse(String).
Returns a non-null valid XMLGregorianCalendar object that holds the
value indicated by the lexicalRepresentation parameter.lexicalRepresentation - Lexical representation of one the eight
XML Schema date/time datatypes.IllegalArgumentException - If the given string does not conform as documented in
parse(String).NullPointerException - If the given string is null.public XMLGregorianCalendarImpl()
Create an instance with all date/time datatype fields set to
DatatypeConstants.FIELD_UNDEFINED or null respectively.
protected XMLGregorianCalendarImpl(BigInteger year, int month, int day, int hour, int minute, int second, BigDecimal fractionalSecond, int timezone)
Private constructor allowing for complete value spaces allowed by
W3C XML Schema 1.0 recommendation for xsd:dateTime and related
builtin datatypes. Note that year parameter supports
arbitrarily large numbers and fractionalSecond has infinite
precision.
year - of XMLGregorianCalendar to be created.month - of XMLGregorianCalendar to be created.day - of XMLGregorianCalendar to be created.hour - of XMLGregorianCalendar to be created.minute - of XMLGregorianCalendar to be created.second - of XMLGregorianCalendar to be created.fractionalSecond - of XMLGregorianCalendar to be created.timezone - of XMLGregorianCalendar to be created.public XMLGregorianCalendarImpl(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() != DatatypeConstants.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 XMLGregorianCalendarpublic 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. DatatypeConstants.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.DatatypeConstants.FIELD_UNDEFINEDpublic 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 dateTimeXMLGregorianCalendar created from parameter values.IllegalArgumentException - if any parameter is outside value constraints for the field as specified in
date/time field mapping table.DatatypeConstants.FIELD_UNDEFINEDpublic 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. DatatypeConstants.FIELD_UNDEFINED indicates optional field is not set.timezone - offset in minutes. DatatypeConstants.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.DatatypeConstants.FIELD_UNDEFINEDpublic 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
DatatypeConstants.FIELD_UNDEFINED.
year - of XMLGregorianCalendar to be created.month - of XMLGregorianCalendar to be created.day - of XMLGregorianCalendar to be created.timezone - offset in minutes. DatatypeConstants.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.DatatypeConstants.FIELD_UNDEFINEDpublic 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. DatatypeConstants.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.DatatypeConstants.FIELD_UNDEFINEDpublic 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. DatatypeConstants.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.DatatypeConstants.FIELD_UNDEFINEDpublic 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. DatatypeConstants.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.DatatypeConstants.FIELD_UNDEFINEDpublic 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 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 XMLGregorianCalendarXMLGregorianCalendar.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.
getEonAndYear in class XMLGregorianCalendareon 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 DatatypeConstants.FIELD_UNDEFINED.
Value constraints for this value are summarized in month field of date/time field mapping table.
getMonth in class 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 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 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 XMLGregorianCalendarsetTime(int, int, int)public int getMinute()
DatatypeConstants.FIELD_UNDEFINED.<\p>
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 XMLGregorianCalendarsetTime(int, int, int)public int getSecond()
Return seconds or DatatypeConstants.FIELD_UNDEFINED.<\p>
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 getMillisecond(),
must not be defined.
Value constraints for this value are summarized in second field of date/time field mapping table.
getSecond in class XMLGregorianCalendarXMLGregorianCalendar.getFractionalSecond(),
getMillisecond(),
setTime(int, int, int)public int getMillisecond()
Return millisecond precision of getFractionalSecond().<\p>
This method represents a convenience accessor to infinite
precision fractional second value returned by
getFractionalSecond(). The returned value is the rounded
down to milliseconds 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.
getMillisecond in class XMLGregorianCalendarXMLGregorianCalendar.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.
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 XMLGregorianCalendarXMLGregorianCalendar.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.
setYear in class XMLGregorianCalendaryear - 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
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 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 XMLGregorianCalendarmonth - 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 DatatypeConstants.FIELD_UNDEFINED.
setDay in class XMLGregorianCalendarday - 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 DatatypeConstants.FIELD_UNDEFINED.
setTimezone in class XMLGregorianCalendaroffset - 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.
setTime in class XMLGregorianCalendarhour - 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 setHour(int hour)
setHour in class XMLGregorianCalendarpublic void setMinute(int minute)
setMinute in class XMLGregorianCalendarpublic void setSecond(int second)
setSecond in class XMLGregorianCalendarpublic void setTime(int hour,
int minute,
int second,
BigDecimal fractional)
Set time as one unit, including the optional infinite precison fractional seconds.
setTime in class XMLGregorianCalendarhour - 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.
setTime in class XMLGregorianCalendarhour - 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 DatatypeConstants.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 int compare(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.
compare in class XMLGregorianCalendarrhs - instance of XMLGregorianCalendar to comparelhs and rhs as
DatatypeConstants.LESSER,
DatatypeConstants.EQUAL,
DatatypeConstants.GREATER or
DatatypeConstants.INDETERMINATE.NullPointerException - if lhs or rhs
parameters are null.public 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 XMLGregorianCalendarpublic boolean equals(Object obj)
Indicates whether parameter obj is "equal to" this one.
equals in class XMLGregorianCalendarobj - to compare.true when compare(this,(XMLGregorianCalendar)obj) == EQUAL..public int hashCode()
Returns a hash code consistent with the definition of the equals method.
hashCode in class XMLGregorianCalendarpublic 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)Except for the noted lexical/canonical representation mismatches listed in XML Schema 1.0 errata, Section 3.2.7.2.
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().
toXMLFormat in class XMLGregorianCalendarString, representation of this XMLGregorianCalendarIllegalStateException - 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 |
DatatypeConstants.DATETIME |
X | X | X | X | X | X |
DatatypeConstants.DATE |
X | X | X | |||
DatatypeConstants.TIME |
X | X | X | |||
DatatypeConstants.GYEARMONTH |
X | X | ||||
DatatypeConstants.GMONTHDAY |
X | X | ||||
DatatypeConstants.GYEAR |
X | |||||
DatatypeConstants.GMONTH |
X | |||||
DatatypeConstants.GDAY |
X | |||||
getXMLSchemaType in class XMLGregorianCalendarDatatypeConstants.DATETIME,
DatatypeConstants.TIME,
DatatypeConstants.DATE,
DatatypeConstants.GYEARMONTH,
DatatypeConstants.GMONTHDAY,
DatatypeConstants.GYEAR,
DatatypeConstants.GMONTH or
DatatypeConstants.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.isValid in class XMLGregorianCalendarpublic 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.
add in class XMLGregorianCalendarduration - Duration to add to this XMLGregorianCalendar.NullPointerException - when duration parameter is null.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 in class XMLGregorianCalendartoGregorianCalendar(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() != DatatypeConstants.FIELD_UNDEFINED,
create a java.util.TimeZone with a custom timezone id
using the this.getTimezone().defaults.getTimezone() != DatatypeConstants.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)toGregorianCalendar in class 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 DatatypeConstants.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 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 DatatypeConstants.FIELD_UNDEFINED, return default timezone for this host. (Same default as java.util.GregorianCalendar).
getTimeZone in class XMLGregorianCalendardefaultZoneoffset - default zoneoffset if this zoneoffset is
DatatypeConstants.FIELD_UNDEFINED.public Object clone()
Creates and returns a copy of this object.
clone in class XMLGregorianCalendarObjectpublic void clear()
Unset all fields to undefined.
Set all int fields to DatatypeConstants.FIELD_UNDEFINED and reference fields
to null.
clear in class XMLGregorianCalendarpublic void setMillisecond(int millisecond)
setMillisecond in class XMLGregorianCalendarpublic void setFractionalSecond(BigDecimal fractional)
setFractionalSecond in class XMLGregorianCalendarpublic void reset()
reset() is designed to allow the reuse of existing
XMLGregorianCalendars thus saving resources associated
with the creation of new XMLGregorianCalendars.
reset in class XMLGregorianCalendarCopyright © 2018–2021 mhoffrogge. All rights reserved.