Class ImmutableXMLGregorianCalendar
- All Implemented Interfaces:
- Cloneable
XMLGregorianCalendar.The following methods throws IllegalStateException:
- clear()
- reset()
- setYear(BigInteger year)
- setYear(int year)
- setMonth(int month)
- setDay(int day)
- setTimezone(int offset)
- setHour(int hour)
- setMinute(int minute)
- setSecond(int second)
- setMillisecond(int millisecond)
- setFractionalSecond(BigDecimal fractional)
- add(Duration duration)
The XMLGregorianCalendar normalize() method returned a new cloned instance that is normalized.
- Author:
- Christopher Mindus
- Constructor SummaryConstructorsConstructorDescriptionConstructs the immutable XMLGregorianCalendar instance, cloning the parameter.
- Method SummaryModifier and TypeMethodDescription- void- void- clear()- clone()Clones the instance.- int- compare- (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.- booleanCompares this calendar to the specified object.- int- getDay()Return day in month or- DatatypeConstants.FIELD_UNDEFINED.- getEon()Return high order component for XML Schema 1.0 dateTime datatype field for- year.Return XML Schema 1.0 dateTime datatype field for- year.Return fractional seconds.- int- getHour()Return hours or- DatatypeConstants.FIELD_UNDEFINED.- intReturn millisecond precision of- getFractionalSecond().- intReturn minutes or- DatatypeConstants.FIELD_UNDEFINED.- int- getMonth()Return number of month or- DatatypeConstants.FIELD_UNDEFINED.- intReturn seconds or- DatatypeConstants.FIELD_UNDEFINED.- intReturn timezone offset in minutes or- DatatypeConstants.FIELD_UNDEFINEDif this optional field is not defined.- getTimeZone- (int defaultZoneoffset) Returns a- java.util.TimeZonefor this class.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- yearor- DatatypeConstants.FIELD_UNDEFINED.- int- hashCode()Returns a hash code consistent with the definition of the equals method.- boolean- isValid()Validate instance by- getXMLSchemaType()constraints.Normalize this instance to UTC.- void- reset()- void- setDay- (int day) - void- setFractionalSecond- (BigDecimal fractional) - void- setHour- (int hour) - void- setMillisecond- (int millisecond) - void- setMinute- (int minute) - void- setMonth- (int month) - void- setSecond- (int second) - void- setTimezone- (int offset) - void- setYear- (int year) - void- setYear- (BigInteger year) Convert this- XMLGregorianCalendarto a- GregorianCalendar.- toGregorianCalendar- (TimeZone timezone, Locale aLocale, XMLGregorianCalendar defaults) Convert this- XMLGregorianCalendaralong with provided parameters to a- GregorianCalendarinstance.- toString()Returns a- Stringrepresentation of this- XMLGregorianCalendar- Object.Return the lexical representation of- thisinstance.- toXMLFormat- (QName datatype) Formats the string in XML for the datatype if possible.- Methods inherited from class javax.xml.datatype.XMLGregorianCalendar- setTime, setTime, setTime
- Constructor Details- ImmutableXMLGregorianCalendarConstructs the immutable XMLGregorianCalendar instance, cloning the parameter.- Parameters:
- xc- The mutable XMLGregorianCalendar instance.
 
 
- Method Details- cloneClones the instance.- Specified by:
- clonein class- XMLGregorianCalendar
- Returns:
- A cloned instance.
 
- getEonReturn high order component for XML Schema 1.0 dateTime datatype field for- year.- nullif 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. - Specified by:
- getEonin class- XMLGregorianCalendar
- Returns:
- eon of this XMLGregorianCalendar. The value returned is an integer multiple of 10^9.
- See Also:
 
- getYearpublic int getYear()Return low order component for XML Schema 1.0 dateTime datatype field for- yearor- DatatypeConstants.FIELD_UNDEFINED.- Value constraints for this value are summarized in year field of date/time field mapping table. - Specified by:
- getYearin class- XMLGregorianCalendar
- Returns:
- year of this XMLGregorianCalendar.
- See Also:
 
- getEonAndYearReturn 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. - Specified by:
- getEonAndYearin class- XMLGregorianCalendar
- Returns:
- sum of eonandBigInteger.valueOf(year)when both fields are defined. When onlyyearis defined, return it. When botheonandyearare not defined, returnnull.
- See Also:
 
- getMonthpublic 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. - Specified by:
- getMonthin class- XMLGregorianCalendar
- Returns:
- year of this XMLGregorianCalendar.
 
- getDaypublic int getDay()Return day in month or- DatatypeConstants.FIELD_UNDEFINED.- Value constraints for this value are summarized in day field of date/time field mapping table. - Specified by:
- getDayin class- XMLGregorianCalendar
 
- getTimezonepublic int getTimezone()Return timezone offset in minutes or- DatatypeConstants.FIELD_UNDEFINEDif this optional field is not defined.- Value constraints for this value are summarized in timezone field of date/time field mapping table. - Specified by:
- getTimezonein class- XMLGregorianCalendar
 
- getHourpublic int getHour()Return hours or- DatatypeConstants.FIELD_UNDEFINED.- Returns - DatatypeConstants.FIELD_UNDEFINEDif this field is not defined.- Value constraints for this value are summarized in hour field of date/time field mapping table. - Specified by:
- getHourin class- XMLGregorianCalendar
 
- getMinutepublic int getMinute()Return minutes or- DatatypeConstants.FIELD_UNDEFINED.- Returns - DatatypeConstants.FIELD_UNDEFINEDif this field is not defined.- Value constraints for this value are summarized in minute field of date/time field mapping table. - Specified by:
- getMinutein class- XMLGregorianCalendar
 
- getSecondpublic int getSecond()Return seconds or- DatatypeConstants.FIELD_UNDEFINED.- Returns - DatatypeConstants.FIELD_UNDEFINEDif 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. - Specified by:
- getSecondin class- XMLGregorianCalendar
- Returns:
- Second of this XMLGregorianCalendar.
- See Also:
 
- getMillisecondpublic int getMillisecond()Return millisecond 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 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. - Overrides:
- getMillisecondin class- XMLGregorianCalendar
- Returns:
- Millisecond of this XMLGregorianCalendar.
- See Also:
 
- getFractionalSecondReturn fractional seconds.- nullis 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.- Specified by:
- getFractionalSecondin class- XMLGregorianCalendar
- Returns:
- fractional seconds of this XMLGregorianCalendar.
- See Also:
 
- compareCompare 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:dateTimedatatype field mapping to accessors of this class are defined in date/time field mapping table.- Specified by:
- comparein class- XMLGregorianCalendar
- Parameters:
- xmlGregorianCalendar- Instance of- XMLGregorianCalendarto compare
- Returns:
- The relationship between thisXMLGregorianCalendarand the specifiedxmlGregorianCalendarasDatatypeConstants.LESSER,DatatypeConstants.EQUAL,DatatypeConstants.GREATERorDatatypeConstants.INDETERMINATE.
- Throws:
- NullPointerException- if- xmlGregorianCalendaris null.
 
- equalsCompares this calendar to the specified object. The result is- trueif and only if the argument is not null and is an- XMLGregorianCalendarobject that represents the same instant in time as this object.- Overrides:
- equalsin class- XMLGregorianCalendar
- Parameters:
- obj- to compare.
- Returns:
- truewhen- objis an instance of- XMLGregorianCalendarand- compare(XMLGregorianCalendar obj)returns- DatatypeConstants.EQUAL, otherwise- false.
 
- hashCodepublic int hashCode()Returns a hash code consistent with the definition of the equals method.- Overrides:
- hashCodein class- XMLGregorianCalendar
- Returns:
- hash code of this object.
 
- toXMLFormatReturn the lexical representation of- thisinstance. 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().- Specified by:
- toXMLFormatin class- XMLGregorianCalendar
- Returns:
- XML, as String, representation of thisXMLGregorianCalendar
- Throws:
- IllegalStateException- if the combination of set fields does not match one of the eight defined XML Schema builtin date/time datatypes.
 
- getXMLSchemaTypeReturn 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 - Specified by:
- getXMLSchemaTypein class- XMLGregorianCalendar
- Returns:
- One of the following class constants: DatatypeConstants.DATETIME,DatatypeConstants.TIME,DatatypeConstants.DATE,DatatypeConstants.GYEARMONTH,DatatypeConstants.GMONTHDAY,DatatypeConstants.GYEAR,DatatypeConstants.GMONTHorDatatypeConstants.GDAY.
- Throws:
- IllegalStateException- if the combination of set fields does not match one of the eight defined XML Schema builtin date/time datatypes.
 
- toStringReturns a- Stringrepresentation of this- XMLGregorianCalendar- Object.- The result is a lexical representation generated by - toXMLFormat().- Overrides:
- toStringin class- XMLGregorianCalendar
- Returns:
- A non-nullvalidStringrepresentation of thisXMLGregorianCalendar.
- Throws:
- IllegalStateException- if the combination of set fields does not match one of the eight defined XML Schema builtin date/time datatypes.
- See Also:
 
- isValidpublic boolean isValid()Validate instance by- getXMLSchemaType()constraints.- Specified by:
- isValidin class- XMLGregorianCalendar
- Returns:
- true if data values are valid.
 
- toGregorianCalendarConvert this- XMLGregorianCalendarto a- GregorianCalendar.- When - thisinstance has an undefined field, this conversion relies on the- java.util.GregorianCalendardefault for its corresponding field. A notable difference between XML Schema 1.0 date/time datatypes and- java.util.GregorianCalendaris 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- TimeZoneinstance, see- toGregorianCalendar(TimeZone, Locale, XMLGregorianCalendar).
 * designates possible loss of precision during the conversion due to source datatype having higher precision than target datatype.- Field by Field Conversion from this class to - java.util.GregorianCalendar- java.util.GregorianCalendarfield- javax.xml.datatype.XMLGregorianCalendarfield- ERA- getEonAndYear()- .signum() < 0 ? GregorianCalendar.BC : GregorianCalendar.AD- YEAR- getEonAndYear()- .abs().intValue()*- MONTH- getMonth()-- DatatypeConstants.JANUARY+- Calendar.JANUARY- DAY_OF_MONTH- getDay()- 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 - GregorianCalendarshould be instantiated in following manner.- Using timeZonevalue as defined above, create a newjava.util.GregorianCalendar(timeZone,Locale.getDefault()).
- Initialize all GregorianCalendar fields by calling Calendar.clear().
- Obtain a pure Gregorian Calendar by invoking GregorianCalendar.setGregorianChange( new Date(Long.MIN_VALUE)).
- Its fields ERA, YEAR, MONTH, DAY_OF_MONTH, HOUR_OF_DAY, MINUTE, SECOND and MILLISECOND are set using the method Calendar.set(int,int)
 - Specified by:
- toGregorianCalendarin class- XMLGregorianCalendar
- See Also:
 
- Using 
- toGregorianCalendarpublic GregorianCalendar toGregorianCalendar- (TimeZone timezone, Locale aLocale, XMLGregorianCalendar defaults) Convert this- XMLGregorianCalendaralong with provided parameters to a- GregorianCalendarinstance.- 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 - timezoneparameter.- To compute the return value's - TimeZonefield,- when parameter timeZoneis non-null, it is the timezone field.
- else when this.getTimezone() != FIELD_UNDEFINED, create ajava.util.TimeZonewith a custom timezone id using thethis.getTimezone().
- else when defaults.getTimezone() != FIELD_UNDEFINED, create ajava.util.TimeZonewith a custom timezone id usingdefaults.getTimezone().
- else use the GregorianCalendardefault timezone value for the host is defined as specified byjava.util.TimeZone.getDefault().
 - To ensure consistency in conversion implementations, the new - GregorianCalendarshould be instantiated in following manner.- Create a new java.util.GregorianCalendar(TimeZone, Locale)with TimeZone set as specified above and theLocaleparameter.
- Initialize all GregorianCalendar fields by calling Calendar.clear()
- Obtain a pure Gregorian Calendar by invoking GregorianCalendar.setGregorianChange( new Date(Long.MIN_VALUE)).
- Its fields ERA, YEAR, MONTH, DAY_OF_MONTH, HOUR_OF_DAY, MINUTE, SECOND and MILLISECOND are set using the method Calendar.set(int,int)
 - Specified by:
- toGregorianCalendarin class- XMLGregorianCalendar
- Parameters:
- timezone- provide Timezone.- nullis 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- nullor a field within the specified- defaultsis undefined, just use- java.util.GregorianCalendardefaults.
- Returns:
- a java.util.GregorianCalendar conversion of this instance.
 
- when parameter 
- getTimeZoneReturns a- java.util.TimeZonefor 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). - Specified by:
- getTimeZonein class- XMLGregorianCalendar
- Parameters:
- defaultZoneoffset- default zoneoffset if this zoneoffset is- DatatypeConstants.FIELD_UNDEFINED.
- Returns:
- TimeZone for this.
 
- toXMLFormatFormats the string in XML for the datatype if possible.- Parameters:
- datatype- The XML date/time datatype.
- Throws:
- IllegalArgumentException- If the datatype
- IllegalStateException- If the combination of set fields does not match one of the eight defined XML Schema built-in date/time datatypes.
 
- clearpublic void clear()- Specified by:
- clearin class- XMLGregorianCalendar
 
- resetpublic void reset()- Specified by:
- resetin class- XMLGregorianCalendar
 
- setYear- Specified by:
- setYearin class- XMLGregorianCalendar
 
- setYearpublic void setYear- (int year) - Specified by:
- setYearin class- XMLGregorianCalendar
 
- setMonthpublic void setMonth- (int month) - Specified by:
- setMonthin class- XMLGregorianCalendar
 
- setDaypublic void setDay- (int day) - Specified by:
- setDayin class- XMLGregorianCalendar
 
- setTimezonepublic void setTimezone- (int offset) - Specified by:
- setTimezonein class- XMLGregorianCalendar
 
- setHourpublic void setHour- (int hour) - Specified by:
- setHourin class- XMLGregorianCalendar
 
- setMinutepublic void setMinute- (int minute) - Specified by:
- setMinutein class- XMLGregorianCalendar
 
- setSecondpublic void setSecond- (int second) - Specified by:
- setSecondin class- XMLGregorianCalendar
 
- setMillisecondpublic void setMillisecond- (int millisecond) - Specified by:
- setMillisecondin class- XMLGregorianCalendar
 
- setFractionalSecond- Specified by:
- setFractionalSecondin class- XMLGregorianCalendar
 
- add- Specified by:
- addin class- 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). - Specified by:
- normalizein class- XMLGregorianCalendar
- Returns:
- A clone()'d instance ofXMLGregorianCalendarnormalized to UTC.