Class XMLGregorianCalendarImpl
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final XMLGregorianCalendarImplUse as a template for default field values when converting to aGregorianCalendar, set to a leap year date of January 1, 0400 at midnight. -
Constructor Summary
ConstructorsModifierConstructorDescriptionCreate an instance with all date/time datatype fields set toDatatypeConstants.FIELD_UNDEFINEDor null respectively.XMLGregorianCalendarImpl(String lexicalRepresentation) Constructs a new XMLGregorianCalendarImpl object.protectedXMLGregorianCalendarImpl(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.Convert ajava.util.GregorianCalendarto XML Schema 1.0 representation. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(DurationImpl duration) Adddurationto this instance.invalid input: '<'\p>voidclear()Unset all fields to undefined.clone()Creates and returns a copy of this object.intCompare 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 XMLGregorianCalendarImplcreateDate(int year, int month, int day, int timezone) Create a Java representation of XML Schema builtin datatypedateorg*.static XMLGregorianCalendarImplcreateDateTime(int year, int month, int day, int hour, int minute, int second) Create a Java instance of XML Schema builtin datatype dateTime.static XMLGregorianCalendarImplcreateDateTime(int year, int month, int day, int hours, int minutes, int seconds, int milliseconds, int timezone) Create a Java representation of XML Schema builtin datatypedateTime.static XMLGregorianCalendarImplcreateDateTime(BigInteger year, int month, int day, int hours, int minutes, int seconds, BigDecimal fractionalSecond, int timezone) Create a Java representation of XML Schema builtin datatypedateTime.static XMLGregorianCalendarImplcreateTime(int hours, int minutes, int seconds, int timezone) Create a Java instance of XML Schema builtin datatypetime.static XMLGregorianCalendarImplcreateTime(int hours, int minutes, int seconds, int milliseconds, int timezone) Create a Java instance of XML Schema builtin datatype time.static XMLGregorianCalendarImplcreateTime(int hours, int minutes, int seconds, BigDecimal fractionalSecond, int timezone) Create a Java instance of XML Schema builtin datatype time.booleanIndicates whether parameterobjis "equal to" this one.intgetDay()Return day in month orDatatypeConstants.FIELD_UNDEFINED.getEon()Return high order component for XML Schema 1.0 dateTime datatype field foryear.Return XML Schema 1.0 dateTime datatype field foryear.Return fractional seconds.intgetHour()Return hours orDatatypeConstants.FIELD_UNDEFINED.intReturn millisecond precision ofgetFractionalSecond().invalid input: '<'\p>intReturn minutes orDatatypeConstants.FIELD_UNDEFINED.invalid input: '<'\p> ReturnsDatatypeConstants.FIELD_UNDEFINEDif this field is not defined.intgetMonth()Return number of month orDatatypeConstants.FIELD_UNDEFINED.intReturn seconds orDatatypeConstants.FIELD_UNDEFINED.invalid input: '<'\p>intReturn timezone offset in minutes orDatatypeConstants.FIELD_UNDEFINEDif this optional field is not defined.getTimeZone(int defaultZoneoffset) Returns ajava.util.TimeZonefor this class.Return the name of the XML Schema date/time type that this instance maps to.intgetYear()Return low order component for XML Schema 1.0 dateTime datatype field foryearorDatatypeConstants.FIELD_UNDEFINED.inthashCode()Returns a hash code consistent with the definition of the equals method.booleanisValid()Validate instance bygetXMLSchemaType()constraints.Normalize this instance to UTC.static XMLGregorianCalendarImplConstructs a new XMLGregorianCalendarImpl object by parsing its lexical string representation as defined in XML Schema 1.0 Part 2, Section 3.2.[7-14].1, Lexical Representation.voidreset()reset()is designed to allow the reuse of existingXMLGregorianCalendarImpls thus saving resources associated with the creation of newXMLGregorianCalendarImpls.voidsetDay(int day) Set days in month.voidsetFractionalSecond(BigDecimal fractional) voidsetHour(int hour) voidsetMillisecond(int millisecond) voidsetMinute(int minute) voidsetMonth(int month) Set month.voidsetSecond(int second) voidsetTime(int hour, int minute, int second) Set time as one unit.voidsetTime(int hour, int minute, int second, int millisecond) Set time as one unit, including optional milliseconds.voidsetTime(int hour, int minute, int second, BigDecimal fractional) Set time as one unit, including the optional infinite precison fractional seconds.voidsetTimezone(int offset) Set the number of minutes in the timezone offset.voidsetYear(int year) Set year of XSDdateTimeyear field.voidsetYear(BigInteger year) Set low and high order component of XSDdateTimeyear field.Convertthistojava.util.GregorianCalendar.toGregorianCalendar(TimeZone timezone, Locale aLocale, XMLGregorianCalendarImpl defaults) Convertthisalong with provided parameters tojava.util.GregorianCalendarinstance.Return the lexical representation ofthisinstance.
-
Field Details
-
FIELD_UNDEFINED
public static final int FIELD_UNDEFINED- See Also:
-
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:dateTimeinstances are defaulted to not being set to any value.XMLGregorianCalendarImplfields millisecond, fractional second and timezone return the value indicating that the field is not set,DatatypeConstants.FIELD_UNDEFINEDfor millisecond and timezone andnullfor fractional second.- See Also:
-
-
Constructor Details
-
XMLGregorianCalendarImpl
Constructs a new XMLGregorianCalendarImpl object. String parsing documented byparse(String). Returns a non-null valid XMLGregorianCalendarImpl object that holds the value indicated by the lexicalRepresentation parameter.- Parameters:
lexicalRepresentation- Lexical representation of one the eight XML Schema date/time datatypes.- Throws:
IllegalArgumentException- If the given string does not conform as documented inparse(String).NullPointerException- If the given string is null.
-
XMLGregorianCalendarImpl
public XMLGregorianCalendarImpl()Create an instance with all date/time datatype fields set to
DatatypeConstants.FIELD_UNDEFINEDor null respectively. -
XMLGregorianCalendarImpl
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
yearparameter supports arbitrarily large numbers and fractionalSecond has infinite precision.- Parameters:
year- ofXMLGregorianCalendarImplto be created.month- ofXMLGregorianCalendarImplto be created.day- ofXMLGregorianCalendarImplto be created.hour- ofXMLGregorianCalendarImplto be created.minute- ofXMLGregorianCalendarImplto be created.second- ofXMLGregorianCalendarImplto be created.fractionalSecond- ofXMLGregorianCalendarImplto be created.timezone- ofXMLGregorianCalendarImplto be created.
-
XMLGregorianCalendarImpl
Convert a
java.util.GregorianCalendarto XML Schema 1.0 representation.Field by Field Conversion from java.util.GregorianCalendarto this classjavax.xml.datatype.XMLGregorianCalendarImplfieldjava.util.GregorianCalendarfieldsetYear(int)ERA == GregorianCalendar.BC ? -YEAR : YEARsetMonth(int)MONTH + 1setDay(int)DAY_OF_MONTHsetTime(int,int,int, BigDecimal)HOUR_OF_DAY, MINUTE, SECOND, MILLISECONDsetTimezone(int)*(ZONE_OFFSET + DST_OFFSET) / (60*1000)
(in minutes)*conversion loss of information. It is not possible to represent a
java.util.GregorianCalendardaylight savings timezone id in the XML Schema 1.0 date/time datatype representation.To compute the return value's
TimeZonefield,- when
this.getTimezone() != FIELD_UNDEFINED, create ajava.util.TimeZonewith a custom timezone id using thethis.getTimezone(). - else use the
GregorianCalendardefault timezone value for the host is defined as specified byjava.util.TimeZone.getDefault().
- Parameters:
cal-java.util.GregorianCalendarused to createXMLGregorianCalendarImpl
- when
-
-
Method Details
-
createDateTime
public static XMLGregorianCalendarImpl 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.- Parameters:
year- represents both high-order eons and low-order year.month- ofdateTimeday- ofdateTimehours- ofdateTimeminutes- ofdateTimeseconds- ofdateTimefractionalSecond- value of null indicates optional field is absent.timezone- offset in minutes.DatatypeConstants.FIELD_UNDEFINEDindicates optional field is not set.- Returns:
XMLGregorianCalendarImplcreated from parameter values.- Throws:
IllegalArgumentException- if any parameter is outside value constraints for the field as specified in date/time field mapping table.- See Also:
-
createDateTime
public static XMLGregorianCalendarImpl createDateTime(int year, int month, int day, int hour, int minute, int second) Create a Java instance of XML Schema builtin datatype dateTime.
- Parameters:
year- represents both high-order eons and low-order year.month- ofdateTimeday- ofdateTimehour- ofdateTimeminute- ofdateTimesecond- ofdateTime- Returns:
XMLGregorianCalendarImplcreated from parameter values.- Throws:
IllegalArgumentException- if any parameter is outside value constraints for the field as specified in date/time field mapping table.- See Also:
-
createDateTime
public static XMLGregorianCalendarImpl 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.- Parameters:
year- represents low-order year.month- ofdateTimeday- ofdateTimehours- ofdateTimeminutes- ofdateTimeseconds- ofdateTimemilliseconds- ofdateTime.DatatypeConstants.FIELD_UNDEFINEDindicates optional field is not set.timezone- offset in minutes.DatatypeConstants.FIELD_UNDEFINEDindicates optional field is not set.- Returns:
XMLGregorianCalendarImplcreated from parameter values.- Throws:
IllegalArgumentException- if any parameter is outside value constraints for the field as specified in date/time field mapping table.- See Also:
-
createDate
Create a Java representation of XML Schema builtin datatype
dateorg*.For example, an instance of
gYearcan be created invoking this factory withmonthanddayparameters set toDatatypeConstants.FIELD_UNDEFINED.- Parameters:
year- ofXMLGregorianCalendarImplto be created.month- ofXMLGregorianCalendarImplto be created.day- ofXMLGregorianCalendarImplto be created.timezone- offset in minutes.DatatypeConstants.FIELD_UNDEFINEDindicates optional field is not set.- Returns:
XMLGregorianCalendarImplcreated from parameter values.- Throws:
IllegalArgumentException- if any parameter is outside value constraints for the field as specified in date/time field mapping table.- See Also:
-
createTime
public static XMLGregorianCalendarImpl createTime(int hours, int minutes, int seconds, int timezone) Create a Java instance of XML Schema builtin datatypetime.- Parameters:
hours- number of hoursminutes- number of minutesseconds- number of secondstimezone- offset in minutes.DatatypeConstants.FIELD_UNDEFINEDindicates optional field is not set.- Returns:
XMLGregorianCalendarImplcreated from parameter values.- Throws:
IllegalArgumentException- if any parameter is outside value constraints for the field as specified in date/time field mapping table.- See Also:
-
createTime
public static XMLGregorianCalendarImpl createTime(int hours, int minutes, int seconds, BigDecimal fractionalSecond, int timezone) Create a Java instance of XML Schema builtin datatype time.
- Parameters:
hours- number of hoursminutes- number of minutesseconds- number of secondsfractionalSecond- value ofnullindicates that this optional field is not set.timezone- offset in minutes.DatatypeConstants.FIELD_UNDEFINEDindicates optional field is not set.- Returns:
XMLGregorianCalendarImplcreated from parameter values.- Throws:
IllegalArgumentException- if any parameter is outside value constraints for the field as specified in date/time field mapping table.- See Also:
-
createTime
public static XMLGregorianCalendarImpl createTime(int hours, int minutes, int seconds, int milliseconds, int timezone) Create a Java instance of XML Schema builtin datatype time.
- Parameters:
hours- number of hoursminutes- number of minutesseconds- number of secondsmilliseconds- number of millisecondstimezone- offset in minutes.DatatypeConstants.FIELD_UNDEFINEDindicates optional field is not set.- Returns:
XMLGregorianCalendarImplcreated from parameter values.- Throws:
IllegalArgumentException- if any parameter is outside value constraints for the field as specified in date/time field mapping table.- See Also:
-
getEon
Return 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.
- Returns:
- eon of this
XMLGregorianCalendarImpl. The value returned is an integer multiple of 10^9. - See Also:
-
getYear
public int getYear()Return low order component for XML Schema 1.0 dateTime datatype field for
yearorDatatypeConstants.FIELD_UNDEFINED.Value constraints for this value are summarized in year field of date/time field mapping table.
- Returns:
- year of this
XMLGregorianCalendarImpl. - See Also:
-
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.
- Returns:
- sum of
eonandBigInteger.valueOf(year)when both fields are defined. When onlyyearis defined, return it. When botheonandyearare not defined, returnnull. - See Also:
-
getMonth
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.
- Returns:
- year of this
XMLGregorianCalendarImpl.
-
getDay
public int getDay()Return day in month orDatatypeConstants.FIELD_UNDEFINED.Value constraints for this value are summarized in day field of date/time field mapping table.
- See Also:
-
getTimezone
public int getTimezone()Return timezone offset in minutes orDatatypeConstants.FIELD_UNDEFINEDif this optional field is not defined.Value constraints for this value are summarized in timezone field of date/time field mapping table.
- See Also:
-
getHour
public int getHour()Return hours orDatatypeConstants.FIELD_UNDEFINED. ReturnsDatatypeConstants.FIELD_UNDEFINEDif this field is not defined.Value constraints for this value are summarized in hour field of date/time field mapping table.
- See Also:
-
getMinute
public int getMinute()Return minutes orDatatypeConstants.FIELD_UNDEFINED.invalid input: '<'\p> ReturnsDatatypeConstants.FIELD_UNDEFINEDif this field is not defined.Value constraints for this value are summarized in minute field of date/time field mapping table.
- See Also:
-
getSecond
public int getSecond()Return seconds or
DatatypeConstants.FIELD_UNDEFINED.invalid input: '<'\p>Returns
DatatypeConstants.FIELD_UNDEFINEDif this field is not defined. When this field is not defined, the optional xs:dateTime fractional seconds field, represented bygetFractionalSecond()andgetMillisecond(), must not be defined.Value constraints for this value are summarized in second field of date/time field mapping table.
- Returns:
- Second of this
XMLGregorianCalendarImpl. - See Also:
-
getMillisecond
public int getMillisecond()Return millisecond precision of
getFractionalSecond().invalid input: '<'\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 ofgetFractionalSecond(). WhengetFractionalSecond()returnsnull, this method must returnDatatypeConstants.FIELD_UNDEFINED.Value constraints for this value are summarized in second field of date/time field mapping table.
- Returns:
- Millisecond of this
XMLGregorianCalendarImpl. - See Also:
-
getFractionalSecond
Return 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 returnDatatypeConstants.FIELD_UNDEFINED).- Returns:
- fractional seconds of this
XMLGregorianCalendarImpl. - See Also:
-
setYear
Set low and high order component of XSD
dateTimeyear field.Unset this field by invoking the setter with a parameter value of
null.- Parameters:
year- value constraints summarized in year field of date/time field mapping table.- Throws:
IllegalArgumentException- ifyearparameter is outside value constraints for the field as specified in date/time field mapping table.
-
setYear
public void setYear(int year) Set year of XSD
dateTimeyear field.Unset this field by invoking the setter with a parameter value of
DatatypeConstants.FIELD_UNDEFINED.Note: if the absolute value of the
yearparameter is less than 10^9, the eon component of the XSD year field is set tonullby this method.- Parameters:
year- value constraints are summarized in year field of date/time field mapping table. If year isDatatypeConstants.FIELD_UNDEFINED, then eon is set tonull.
-
setMonth
public void setMonth(int month) Set month.
Unset this field by invoking the setter with a parameter value of
DatatypeConstants.FIELD_UNDEFINED.- Parameters:
month- value constraints summarized in month field of date/time field mapping table.- Throws:
IllegalArgumentException- ifmonthparameter is outside value constraints for the field as specified in date/time field mapping table.
-
setDay
public void setDay(int day) Set days in month.
Unset this field by invoking the setter with a parameter value of
DatatypeConstants.FIELD_UNDEFINED.- Parameters:
day- value constraints summarized in day field of date/time field mapping table.- Throws:
IllegalArgumentException- ifdayparameter is outside value constraints for the field as specified in date/time field mapping table.
-
setTimezone
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.- Parameters:
offset- value constraints summarized in timezone field of date/time field mapping table.- Throws:
IllegalArgumentException- ifoffsetparameter is outside value constraints for the field as specified in date/time field mapping table.
-
setTime
public void setTime(int hour, int minute, int second) Set time as one unit.
- Parameters:
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.- Throws:
IllegalArgumentException- if any parameter is outside value constraints for the field as specified in date/time field mapping table.- See Also:
-
setHour
public void setHour(int hour) -
setMinute
public void setMinute(int minute) -
setSecond
public void setSecond(int second) -
setTime
Set time as one unit, including the optional infinite precison fractional seconds.
- Parameters:
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 ofnullindicates this optional field is not set.- Throws:
IllegalArgumentException- if any parameter is outside value constraints for the field as specified in date/time field mapping table.
-
setTime
public void setTime(int hour, int minute, int second, int millisecond) Set time as one unit, including optional milliseconds.
- Parameters:
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 ofDatatypeConstants.FIELD_UNDEFINEDindicates this optional field is not set.- Throws:
IllegalArgumentException- if any parameter is outside value constraints for the field as specified in date/time field mapping table.
-
compare
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:dateTimedatatype field mapping to accessors of this class are defined in date/time field mapping table.- Parameters:
rhs- instance ofXMLGregorianCalendarImplto compare- Returns:
- the relationship between
lhsandrhsasDatatypeConstants.LESSER,DatatypeConstants.EQUAL,DatatypeConstants.GREATERorDatatypeConstants.INDETERMINATE. - Throws:
NullPointerException- iflhsorrhsparameters are null.
-
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).
-
equals
Indicates whether parameter
objis "equal to" this one. -
hashCode
public int hashCode()Returns a hash code consistent with the definition of the equals method.
-
parse
Constructs a new XMLGregorianCalendarImpl 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 XMLGregorianCalendarImpl(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 XMLGregorianCalendarImpl object that holds the value indicated by the lexicalRepresentation parameter.
- Parameters:
lexicalRepresentation- Lexical representation of one the 8 XML Schema calendar datatypes.- Returns:
XMLGregorianCalendarImplcreated from parsinglexicalRepresentationparameter.- Throws:
IllegalArgumentException- If the given string does not conform to the aforementioned specification.NullPointerException- If the given string is null.
-
toXMLFormat
Return 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().- Returns:
- XML, as
String, representation of thisXMLGregorianCalendarImpl - Throws:
IllegalStateException- if the combination of set fields does not match one of the eight defined XML Schema builtin date/time datatypes.
-
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.DATETIMEX X X X X X DatatypeConstants.DATEX X X DatatypeConstants.TIMEX X X DatatypeConstants.GYEARMONTHX X DatatypeConstants.GMONTHDAYX X DatatypeConstants.GYEARX DatatypeConstants.GMONTHX DatatypeConstants.GDAYX - 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.
-
isValid
public boolean isValid()Validate instance bygetXMLSchemaType()constraints.- Returns:
- true if data values are valid.
-
add
Add
durationto this instance.invalid input: '<'\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
dateTimefields to this class' representation of those fields.- Parameters:
duration- DurationImpl to add to thisXMLGregorianCalendarImpl.- Throws:
NullPointerException- whendurationparameter isnull.
-
toGregorianCalendar
Convert
thistojava.util.GregorianCalendar.When
thisinstance has an undefined field, this conversion relies on thejava.util.GregorianCalendardefault for its corresponding field. A notable difference between XML Schema 1.0 date/time datatypes andjava.util.GregorianCalendaris that Timezone value is optional for date/time datatypes and it is a required field forjava.util.GregorianCalendar. See javadoc forjava.util.TimeZone.getDefault()on how the default is determined. To explicitly specify theTimeZoneinstance, seetoGregorianCalendar(TimeZone, Locale, XMLGregorianCalendarImpl).
* designates possible loss of precision during the conversion due to source datatype having higer precison than target datatype.Field by Field Conversion from this class to java.util.GregorianCalendarjava.util.GregorianCalendarfieldjavax.xml.datatype.XMLGregorianCalendarImplfieldERAgetEonAndYear().signum() invalid input: '<' 0 ? GregorianCalendar.BC : GregorianCalendar.ADYEARgetEonAndYear().abs().intValue()*MONTHgetMonth()- 1DAY_OF_MONTHgetDay()AM_PMgetHour()invalid input: '<' 12 : Calendar.AM : Calendar.PMHOUR_OF_DAYgetHour()MINUTEgetMinute()SECONDgetSecond()MILLISECONDget millisecond order from getFractionalSecond()*GregorianCalendar.setTimeZone(TimeZone)getTimezone()formatted into Custom timezone idTo 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 {(@link GegorianCalendar#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)
- See Also:
- Using
-
toGregorianCalendar
public GregorianCalendar toGregorianCalendar(TimeZone timezone, Locale aLocale, XMLGregorianCalendarImpl defaults) Convert
thisalong with provided parameters tojava.util.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 definedas specified byjava.util.TimeZone.getDefault(). - Create a new
java.util.GregorianCalendar(TimeZone, Locale)with TimeZone set as specified above and theLocaleparameter. - Initialize all GregorianCalendar fields by calling {(@link GegorianCalendar#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)
To ensure consistency in conversion implementations, the new
GregorianCalendarshould be instantiated in following manner.- Parameters:
timezone- provide Timezone.nullis a legal value.aLocale- provide explicit Locale. Use default GregorianCalendar locale if value isnull.defaults- provide default field values to use when corresponding field for this instance is FIELD_UNDEFINED or null. Ifdefaultsisnullor a field within the specifieddefaultsis undefined, just usejava.util.GregorianCalendardefaults.- Returns:
- a java.util.GregorianCalendar conversion of this instance.
- See Also:
- when parameter
-
getTimeZone
Returns 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).
- Parameters:
defaultZoneoffset- default zoneoffset if this zoneoffset isDatatypeConstants.FIELD_UNDEFINED.- Returns:
- TimeZone for this.
-
clone
Creates and returns a copy of this object.
-
clear
public void clear()Unset all fields to undefined.
Set all int fields to
DatatypeConstants.FIELD_UNDEFINEDand reference fields to null. -
setMillisecond
public void setMillisecond(int millisecond) -
setFractionalSecond
-
reset
public void reset()reset()is designed to allow the reuse of existingXMLGregorianCalendarImpls thus saving resources associated with the creation of newXMLGregorianCalendarImpls.
-