TopBlend: Here is the first difference. There are 391 differences. is old. is new.

javax.xml.datatype
Class XMLGregorianCalendar


java.lang.Object
  extended by javax.xml.datatype.XMLGregorianCalendar
All Implemented Interfaces:
Cloneable Serializable , Cloneable

public abstract class XMLGregorianCalendar
extends Object
implements CloneableSerializable, 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()
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() or
getEonAndYear()
getYear() is a value between -(10^9-1) to (10^9)-1 or DatatypeConstants.FIELD_UNDEFINED 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 FIELD_UNDEFINED
day getDay() Independent of month, max range is 1 to 31 or DatatypeConstants.FIELD_UNDEFINED FIELD_UNDEFINED .
The normative value constraint stated relative to month field's value is in W3C XML Schema 1.0 Part 2, Appendix D .
hour getHour() 0 to 24 or DatatypeConstants.FIELD_UNDEFINED . For a value of 24, the minute and second field must be zero per XML Schema Errata .
hour getHour() 0 to 23 or FIELD_UNDEFINED
minute getMinute() 0 to 59 or DatatypeConstants.FIELD_UNDEFINED FIELD_UNDEFINED
second getSecond()
second getSecond() + getMillisecond() /1000 or
getSecond() + getFractionalSecond()
getSecond() from 0 to 60 or DatatypeConstants.FIELD_UNDEFINED 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 when the getSecond() is defined. 1.0.
FractionalSecond is optional and has a value of null when it is undefined.
getMillisecond()
timezone getTimezone() is the convenience millisecond precision of value of getFractionalSecond() Number of minutes or FIELD_UNDEFINED . Value range from -14 hours (-14 * 60 minutes) to 14 hours (14 * 60 minutes) exclusive.
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, @{link DatatypeFactory},setter 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:

Since:
1.5
See Also:
Duration , DatatypeFactory 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
 
Method Summary
abstract  void add ( Duration
          Add duration to this instance. <\p>
abstract  void clear ()
          Unset all fields to undefined.
abstract   Object clone ()
          Creates and returns a copy of this object.
abstract  int static int compare compare ( XMLGregorianCalendar  lhs, 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
 boolean equals ( Object
          Indicates whether parameter obj is "equal to" this one.
static  XMLGregorianCalendar createDate (int year, int month, int day, int timezone)
          Create a Java representation of XML Schema builtin datatype date or g*.
abstract  int getDay ()
          Return day in month or DatatypeConstants.FIELD_UNDEFINED
static  XMLGregorianCalendar createDateTime ( BigInteger  year, int month, int day, int hours, int minutes, int seconds, BigDecimal
          Create a Java representation of XML Schema builtin datatype dateTime.
abstract   BigInteger getEon ()
          Return high order component for XML Schema 1.0 dateTime datatype field for year.
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.
abstract   BigInteger getEonAndYear ()
          Return XML Schema 1.0 dateTime datatype field for year.
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.
abstract   BigDecimal getFractionalSecond ()
          Return fractional seconds.
static  XMLGregorianCalendar createTime (int hours, int minutes, int seconds, BigDecimal
          Create a Java instance of XML Schema builtin datatype time.
abstract  int getHour ()
          Return hours or DatatypeConstants.FIELD_UNDEFINED
static  XMLGregorianCalendar createTime (int hours, int minutes, int seconds, int timezone)
          Create a Java instance of XML Schema builtin datatype time.
 int getMillisecond ()
          Return millisecond precision of getFractionalSecond() <\p>
static  XMLGregorianCalendar createTime (int hours, int minutes, int seconds, int milliseconds, int timezone)
          Create a Java instance of XML Schema builtin datatype time.
abstract  int getMinute ()
          Return minutes or DatatypeConstants.FIELD_UNDEFINED <\p> Returns DatatypeConstants.FIELD_UNDEFINED
 boolean equals ( Object
          Indicates whether parameter obj is "equal to" this one.
abstract  int getMonth ()
          Return number of month or DatatypeConstants.FIELD_UNDEFINED
static  XMLGregorianCalendar fromGregorianCalendar ( GregorianCalendar
          Convert a java.util.GregorianCalendar to XML Schema 1.0 representation.
abstract  int getSecond getDay ()
          Return seconds day in month or DatatypeConstants.FIELD_UNDEFINED FIELD_UNDEFINED <\p>
abstract  int getTimezone ()
          Return timezone offset in minutes or DatatypeConstants.FIELD_UNDEFINED
  BigInteger getEon ()
          Get the eons of the year.
abstract   TimeZone BigInteger getTimeZone getEonAndYear (int defaultZoneoffset) ()
          Returns a java.util.TimeZone           Return XML Schema 1.0 dateTime datatype field for this class. year.
abstract   QName BigDecimal getXMLSchemaType getFractionalSecond ()
          Return the name of the XML Schema date/time type that this instance maps to. fractional seconds.
abstract  int getYear getHour ()
          Return low order component for XML Schema 1.0 dateTime datatype field for year hours or DatatypeConstants.FIELD_UNDEFINED FIELD_UNDEFINED
 int hashCode getMillisecond ()
          Returns a hash code consistent with the definition of the equals method.           Return milliseconds or FIELD_UNDEFINED <\p>
abstract  boolean  int isValid getMinute ()
          Validate instance by getXMLSchemaType() constraints.           Return minutes or FIELD_UNDEFINED <\p> Returns FIELD_UNDEFINED
abstract   XMLGregorianCalendar  int normalize getMonth ()
          Normalize this instance to UTC.           Return number of month or FIELD_UNDEFINED
abstract  void  int reset getSecond ()
          Reset this XMLGregorianCalendar to its original values.           Return seconds or FIELD_UNDEFINED <\p>
abstract  void  int setDay getTimezone (int day) ()
          Set days           Return timezone offset in month. minutes or FIELD_UNDEFINED
abstract  void setFractionalSecond ( BigDecimal
          Set fractional seconds.
  QName getXMLSchemaType ()
          Return the name of the XML Schema date/time type that this instance maps to.
abstract  void setHour (int hour)
          Set hours.
 int getYear ()
          Return low order component XML Schema 1.0 dataTime datatype field for year or FIELD_UNDEFINED
abstract  void setMillisecond (int millisecond)
          Set milliseconds.
 int hashCode ()
          Returns a hash code consistent with the definition of the equals method.
abstract  void  boolean setMinute isValid (int minute) ()
          Set minutes.           Validate instance by getXMLSchemaType() constraints.
abstract  void setMonth (int month)
          Set month.
static  XMLGregorianCalendar parse ( String
          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 .
abstract  void setSecond setDay (int second) (int day)
          Set seconds. 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
          Set time as one unit, including the optional infinite precision precison fractional seconds.
 void setTime (int hour, int minute, int second, int millisecond)
          Set time as one unit, including optional milliseconds.
abstract  void setTimezone (int offset)
          Set the number of minutes in the timezone offset.
abstract  void setYear ( BigInteger
          Set low and high order component of XSD dateTime year field.
abstract  void setYear (int year)
          Set year of XSD dateTime year field.
abstract   GregorianCalendar toGregorianCalendar ()
          Convert this XMLGregorianCalendar to a GregorianCalendar java.util.GregorianCalendar.
abstract   GregorianCalendar toGregorianCalendar ( TimeZone  timezone, Locale  aLocale, XMLGregorianCalendar
          Convert this XMLGregorianCalendar along with provided parameters to a GregorianCalendar java.util.GregorianCalendar instance.
  String toString toXMLFormat ()
          Return a human readable String the lexical representation of this XMLGregorianCalendar. instance.
abstract   String toXMLFormat ()
          Return the lexical representation of this instance.
 
Methods inherited from class java.lang. Object
finalize , getClass , notify , notifyAll , toString , wait , wait , wait
 

Constructor Field Detail

XMLGregorianCalendar JANUARY


public 
public static final int XMLGregorianCalendar JANUARY () 
Value for first month of year.

See Also:
getMonth() , setMonth(int) , Constant Field Values

Method Detail

clear FEBRUARY


public abstract void 
public static final int clear FEBRUARY () 
Value for second month of year.

Unset all fields to undefined.

Set all int fields to DatatypeConstants.FIELD_UNDEFINED

See Also:
getMonth() and reference fields to null.

, setMonth(int) , Constant Field Values

MARCH


public static final int MARCH 
Value for third month of year.

See Also:
getMonth() , setMonth(int) , Constant Field Values

APRIL


public static final int APRIL 
Value for fourth month of year.

See Also:
getMonth() , setMonth(int) , Constant Field Values

reset MAY


public abstract void 
public static final int reset MAY () 
Value for fifth month of year.

Reset this XMLGregorianCalendar to its original values.

XMLGregorianCalendar is reset to the same values as when it was created with DatatypeFactory.newXMLGregorianCalendar()

See Also:
getMonth() , DatatypeFactory.newXMLGregorianCalendar(String lexicalRepresentation) setMonth(int) , DatatypeFactory.newXMLGregorianCalendar( BigInteger year, int month, int day, int hour, int minute, int second, BigDecimal fractionalSecond, int timezone) Constant Field Values , DatatypeFactory.newXMLGregorianCalendar( int year, int month, int day, int hour, int minute, int second, int millisecond, int timezone)

, DatatypeFactory.newXMLGregorianCalendar(GregorianCalendar cal)

JUNE


public static final int JUNE 
Value for sixth month of year.

See Also:
getMonth() , DatatypeFactory.newXMLGregorianCalendarDate( int year, int month, int day, int timezone) setMonth(int) , DatatypeFactory.newXMLGregorianCalendarTime( int hours, int minutes, int seconds, int timezone) Constant Field Values , DatatypeFactory.newXMLGregorianCalendarTime( int hours, int minutes, int seconds, BigDecimal fractionalSecond, int timezone)

or DatatypeFactory.newXMLGregorianCalendarTime( int hours, int minutes, int seconds, int milliseconds, int timezone) .

JULY


public static final int JULY 
Value for seventh month of year.

reset() is designed to allow the reuse of existing XMLGregorianCalendars thus saving resources associated with the creation of new XMLGregorianCalendars.

See Also:
getMonth() , setMonth(int) , Constant Field Values

AUGUST


public static final int AUGUST 
Value for eighth month of year.

See Also:
getMonth() , setMonth(int) , Constant Field Values

setYear SEPTEMBER


public abstract void 
public static final int setYear SEPTEMBER ( BigInteger year) 
Value for ninth month of 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.

See Also:
getMonth() , setMonth(int) , Constant Field Values

OCTOBER


public static final int OCTOBER 
Value for tenth month of year.

Parameters: See Also:
year - value constraints summarized in year field of date/time field mapping table getMonth() . , setMonth(int) , Constant Field Values

NOVEMBER


public static final int NOVEMBER 
Value for eleven month of year.

Throws: See Also:
IllegalArgumentException getMonth() - if year parameter is outside value constraints for the field as specified in date/time field mapping table , setMonth(int) . , Constant Field Values

setYear DECEMBER


public abstract void 
public static final int setYear DECEMBER (int year) 
Value for twelve month of year.

Set year of XSD dateTime year field.

Unset this field by invoking the setter with a parameter value of DatatypeConstants.FIELD_UNDEFINED

See Also:
getMonth() .

, setMonth(int) , Constant Field Values

FIELD_UNDEFINED


public static final int FIELD_UNDEFINED 
Designation that an "int" field is not set.

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.

See Also:
Constant Field Values

LESSER


public static final int LESSER 
Partial order relation comparison result.

Parameters: See Also:
year - value constraints are summarized in year field of date/time field mapping table compare(XMLGregorianCalendar, XMLGregorianCalendar) . If year is DatatypeConstants.FIELD_UNDEFINED , Constant Field Values , then eon is set to null.

setMonth EQUAL


public abstract void 
public static final int setMonth EQUAL (int month) 
Partial order relation comparison result.

Set month.

Unset this field by invoking the setter with a parameter value of DatatypeConstants.FIELD_UNDEFINED

See Also:
compare(XMLGregorianCalendar, XMLGregorianCalendar) .

, Constant Field Values

GREATER


public static final int GREATER 
Partial order relation comparison result.

Parameters: See Also:
month - value constraints summarized in month field of date/time field mapping table compare(XMLGregorianCalendar, XMLGregorianCalendar) . , Constant Field Values

INDETERMINATE


public static final int INDETERMINATE 
Partial order relation comparison result.

Throws: See Also:
IllegalArgumentException compare(XMLGregorianCalendar, XMLGregorianCalendar) - if month parameter is outside value constraints for the field as specified in date/time field mapping table , Constant Field Values .

setDay LEAP_YEAR_DEFAULT


public abstract void 
public static final XMLGregorianCalendarsetDay LEAP_YEAR_DEFAULT (int day) 

Set days in month. 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.

Unset this field by invoking the setter with a parameter value of DatatypeConstants.FIELD_UNDEFINED .

Parameters: See Also:
day - value constraints summarized in day field of date/time field mapping table toGregorianCalendar(TimeZone, Locale, XMLGregorianCalendar) .

DATETIME


public static final QNameThrows: DATETIME 
IllegalArgumentException

Fully qualified name for W3C XML Schema 1.0 datatype dateTime.


- if day parameter is outside value constraints for the field as specified in date/time field mapping table

TIME


public static final QName. TIME 

Fully qualified name for W3C XML Schema 1.0 datatype time.


setTimezone DATE


public abstract void 
public static final QNamesetTimezone DATE (int offset) 

Set the number of minutes in the timezone offset. Fully qualified name for W3C XML Schema 1.0 datatype date.

Unset this field by invoking the setter with a parameter value of DatatypeConstants.FIELD_UNDEFINED


.

GYEARMONTH


public static final QNameGYEARMONTH 

Fully qualified name for W3C XML Schema 1.0 datatype gYearMonth.


GMONTHDAY


public static final QNameGMONTHDAY 

Fully qualified name for W3C XML Schema 1.0 datatype gMonthDay.


GYEAR


public static final QNameParameters: GYEAR 
offset - value constraints summarized in timezone field of date/time field mapping table

Fully qualified name for W3C XML Schema 1.0 datatype gYear.


.

GMONTH


public static final QNameThrows: GMONTH 
IllegalArgumentException - if offset parameter is outside value constraints for the field as specified in date/time field mapping table .

Fully qualified name for W3C XML Schema 1.0 datatype gMonth.


setTime GDAY


public void 
public static final QNamesetTime GDAY (int hour,
 int minute,
 int second) 

Set time as one unit. Fully qualified name for W3C XML Schema 1.0 datatype gDay.


MAX_TIMEZONE_OFFSET


public static final int MAX_TIMEZONE_OFFSET 
W3C XML Schema max timezone offset is -14:00. Zone offset is in minutes.

Parameters: See Also:
hour - value constraints are summarized in hour field of date/time field mapping table Constant Field Values .
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 .

MIN_TIMEZONE_OFFSET


public static final int Throws: MIN_TIMEZONE_OFFSET 
IllegalArgumentException - if any parameter is outside value constraints for the field as specified in date/time field mapping table . W3C XML Schema min timezone offset is +14:00. Zone offset is in minutes.

See Also:
setTime(int, int, int, BigDecimal) Constant Field Values

Constructor Detail

setHour XMLGregorianCalendar

public abstract void setHour XMLGregorianCalendar (int hour) () 

Set hours. Create an instance with all date/time datatype fields set to FIELD_UNDEFINED or null respectively.

Unset this field by invoking the setter with a parameter value of DatatypeConstants.FIELD_UNDEFINED

.
Method Detail

createDateTime


public static XMLGregorianCalendarcreateDateTime ( 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:
hour - value constraints summarized in hour field of date/time field mapping table year - represents both high-order eons and low-order year.
month - of dateTime
day - of dateTime
hours - of dateTime
minutes - of dateTime
seconds - of dateTime
fractionalSecond - value of null indicates optional field is absent.
timezone - offset in minutes. FIELD_UNDEFINED . indicates optional field is not set.
Returns:
XMLGregorianCalendar created from parameter values.
Throws:
IllegalArgumentException - if hour any parameter is outside value constraints for the field as specified in date/time field mapping table .
See Also:
FIELD_UNDEFINED

setMinute createDateTime


public abstract void 
public static XMLGregorianCalendarsetMinute createDateTime (int minute) (int year,
 int month,
 int day,
 int hour,
 int minute,
 int second) 

Set minutes. Create a Java instance of XML Schema builtin datatype dateTime.

Unset this field by invoking the setter with a parameter value of DatatypeConstants.FIELD_UNDEFINED .

Parameters:
minute - value constraints summarized in minute field of date/time field mapping table . year - represents both high-order eons and low-order year.
month - of dateTime
day - of dateTime
hour - of dateTime
minute - of dateTime
second - of dateTime
Returns:
XMLGregorianCalendar created from parameter values.
Throws:
IllegalArgumentException - if minute any parameter is outside value constraints for the field as specified in date/time field mapping table .
See Also:
FIELD_UNDEFINED

setSecond createDateTime


public abstract void 
public static XMLGregorianCalendarsetSecond createDateTime (int second) (int year,
 int month,
 int day,
 int hours,
 int minutes,
 int seconds,
 int milliseconds,
 int timezone) 

Set seconds. Create a Java representation of XML Schema builtin datatype dateTime. All possible fields are specified for this factory method.

Unset this field by invoking the setter with a parameter value of DatatypeConstants.FIELD_UNDEFINED .

Parameters:
second - value constraints summarized in second field of date/time field mapping table year - represents low-order year.
month - of dateTime
day - of dateTime
hours - of dateTime
minutes - of dateTime
seconds - of dateTime
milliseconds - of dateTime. FIELD_UNDEFINED . indicates optional field is not set.
timezone - offset in minutes. FIELD_UNDEFINED indicates optional field is not set.
Returns:
XMLGregorianCalendar created from parameter values.
Throws:
IllegalArgumentException - if second any parameter is outside value constraints for the field as specified in date/time field mapping table .
See Also:
FIELD_UNDEFINED

setMillisecond createDate


public abstract void 
public static XMLGregorianCalendarsetMillisecond createDate (int millisecond) (int year,
 int month,
 int day,
 int timezone) 

Set milliseconds. Create a Java representation of XML Schema builtin datatype date or g*.

Unset this field by invoking the setter with a parameter value of DatatypeConstants.FIELD_UNDEFINED For example, an instance of gYear can be created invoking this factory with month and day parameters set to FIELD_UNDEFINED .

Parameters:
millisecond - value constraints summarized in millisecond field of date/time field mapping table 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.
Returns:
XMLGregorianCalendar created from parameter values.
Throws:
IllegalArgumentException - if millisecond any parameter is outside value constraints for the field as specified in date/time field mapping table .
See Also:
FIELD_UNDEFINED

setFractionalSecond createTime


public abstract void 
public static XMLGregorianCalendarsetFractionalSecond createTime ( BigDecimal fractional) (int hours,
 int minutes,
 int seconds,
 int timezone) 
Create a Java instance of XML Schema builtin datatype time.

Set fractional seconds.

Unset this field by invoking the setter with a parameter value of null.

Parameters:
fractional - value constraints summarized in fractional field of date/time field mapping table hours - number of hours
minutes - number of minutes
seconds - number of seconds
timezone - offset in minutes. FIELD_UNDEFINED . indicates optional field is not set.
Returns:
XMLGregorianCalendar created from parameter values.
Throws:
IllegalArgumentException - if fractional any parameter is outside value constraints for the field as specified in date/time field mapping table .
See Also:
FIELD_UNDEFINED

setTime createTime


public void 
public static XMLGregorianCalendarsetTime createTime (int hour,
 int minute,
 int second,
 BigDecimal(int hours,
 int minutes,
 int seconds,
 BigDecimal fractional)  fractionalSecond,
 int timezone) 

Set time as one unit, including the optional infinite precision fractional seconds. Create a Java instance of XML Schema builtin datatype time.

Parameters:
hour - value constraints are summarized in hour field of date/time field mapping table . hours - number of hours
minute - value constraints are summarized in minute field of date/time field mapping table . minutes - number of minutes
second - value constraints are summarized in second field of date/time field mapping table seconds - number of seconds
fractionalSecond - value of null indicates that this optional field is not set.
timezone - offset in minutes. FIELD_UNDEFINED . indicates optional field is not set.
Returns:
fractional - value of null indicates this optional field is not set. XMLGregorianCalendar created 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:
FIELD_UNDEFINED

setTime createTime


public void 
public static XMLGregorianCalendarsetTime createTime (int hour,
 int minute,
 int second,
 int millisecond) (int hours,
 int minutes,
 int seconds,
 int milliseconds,
 int timezone) 

Set time as one unit, including optional milliseconds. Create a Java instance of XML Schema builtin datatype time.

Parameters:
hour - value constraints are summarized in hour field of date/time field mapping table . hours - number of hours
minute - value constraints are summarized in minute field of date/time field mapping table . minutes - number of minutes
second - value constraints are summarized in second field of date/time field mapping table seconds - number of seconds
milliseconds - number of milliseconds
timezone - offset in minutes. FIELD_UNDEFINED . indicates optional field is not set.
Returns:
millisecond - value of DatatypeConstants.FIELD_UNDEFINED indicates this optional field is not set. XMLGregorianCalendar created 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:
FIELD_UNDEFINED

getEon

public abstract BigInteger getEon()

Return high order component for XML Schema 1.0 dateTime datatype field for year. 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 .

Returns:
eon of this XMLGregorianCalendar. The value returned is an integer multiple of 10^9.
See Also:
getYear() , getEonAndYear()

getYear

public abstract int getYear()

Return low order component for XML Schema 1.0 dateTime dataTime datatype field for year or DatatypeConstants.FIELD_UNDEFINED FIELD_UNDEFINED .

Value constraints for this value are summarized in year field of date/time field mapping table .

Returns:
year of this XMLGregorianCalendar.
See Also:
getEon() , getEonAndYear()

getEonAndYear

public abstract 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 .

Returns:
sum of 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.
See Also:
getEon() , getYear()

getMonth

public abstract int getMonth()

Return number of month or DatatypeConstants.FIELD_UNDEFINED FIELD_UNDEFINED .

Value constraints for this value are summarized in month field of date/time field mapping table .

Returns:
year of this XMLGregorianCalendar.

getDay

public abstract int getDay()
Return day in month or DatatypeConstants.FIELD_UNDEFINED FIELD_UNDEFINED .

Value constraints for this value are summarized in day field of date/time field mapping table .

See Also:
setDay(int)

getTimezone

public abstract int getTimezone()
Return timezone offset in minutes or DatatypeConstants.FIELD_UNDEFINED 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 .

See Also:
setTimezone(int)

getHour

public abstract int getHour()
Return hours or DatatypeConstants.FIELD_UNDEFINED FIELD_UNDEFINED . Returns DatatypeConstants.FIELD_UNDEFINED FIELD_UNDEFINED if this field is not defined.

Value constraints for this value are summarized in hour field of date/time field mapping table .

See Also:
setTime(int, int, int)

getMinute

public abstract int getMinute()
Return minutes or DatatypeConstants.FIELD_UNDEFINED FIELD_UNDEFINED .<\p> Returns DatatypeConstants.FIELD_UNDEFINED FIELD_UNDEFINED if this field is not defined.

Value constraints for this value are summarized in minute field of date/time field mapping table .

See Also:
setTime(int, int, int)

getSecond

public abstract int getSecond()

Return seconds or DatatypeConstants.FIELD_UNDEFINED FIELD_UNDEFINED .<\p>

Returns DatatypeConstants.FIELD_UNDEFINED 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 .

Returns:
Second of this XMLGregorianCalendar.
See Also:
getFractionalSecond() , getMillisecond() , setTime(int, int, int)

getMillisecond

public int getMillisecond()

Return millisecond precision of getFractionalSecond() Return milliseconds or FIELD_UNDEFINED .<\p>

This method represents a convenience accessor to infinite precision fractional second value returned by getFractionalSecond() Returns FIELD_UNDEFINED . The returned value is the rounded down to milliseconds value of getFractionalSecond() . When getFractionalSecond() returns null, this method must return DatatypeConstants.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 .

Returns:
Millisecond of this XMLGregorianCalendar.
See Also:
getFractionalSecond() , setTime(int, int, int)

getFractionalSecond

public abstract 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 .

Returns:
fractional seconds of this XMLGregorianCalendar.
See Also:
getSecond() , setTime(int, int, int, BigDecimal)

compare setYear


public abstract int 
public void compare setYear ( XMLGregorianCalendarBigInteger xmlGregorianCalendar)  year) 

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 Set low and high order component of XSD dateTime year 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 - if year parameter 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 dateTime year field.

xsd:dateTime datatype field mapping to accessors of this class are defined in date/time field mapping table Unset this field by invoking the setter with a parameter value of FIELD_UNDEFINED .

Parameters:
xmlGregorianCalendar - Instance of XMLGregorianCalendar to compare 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.

setMonth


public void setMonth (int month) 

Set month.

Unset this field by invoking the setter with a parameter value of FIELD_UNDEFINED .

Returns: Parameters:
The relationship between this XMLGregorianCalendar and the specified xmlGregorianCalendar as DatatypeConstants.LESSER month - value constraints summarized in month field of date/time field mapping table , DatatypeConstants.EQUAL .
Throws:
IllegalArgumentException , DatatypeConstants.GREATER - if month parameter is outside value constraints for the field as specified in date/time field mapping table or DatatypeConstants.INDETERMINATE .

setDay


public void setDay (int day) 

Set days in month.

Unset this field by invoking the setter with a parameter value of FIELD_UNDEFINED .

Parameters:
day - value constraints summarized in day field of date/time field mapping table .
Throws:
NullPointerException IllegalArgumentException - if xmlGregorianCalendar is null. - if day parameter is outside value constraints for the field as specified in date/time field mapping table .

normalize setTimezone


public abstract XMLGregorianCalendar
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 .

normalize Parameters: ()
offset - value constraints summarized in timezone field of date/time field mapping table .
Throws:
IllegalArgumentException - if offset 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) 

Normalize this instance to UTC. Set time as one unit.

2000-03-04T23:00:00+03:00 normalizes to 2000-03-04T20:00:00Z

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:
setTime(int, int, int, BigDecimal)

setTime


public void setTime (int hour,
 int minute,
 int second,
 BigDecimal fractional) 

Set time as one unit, including the optional infinite precison fractional seconds.

Implements W3C XML Schema Part 2, Section 3.2.7.3 (A).

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 of null indicates 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 of FIELD_UNDEFINED indicates 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


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 .

Parameters:
lhs - instance of XMLGregorianCalendar to compare
rhs - instance of XMLGregorianCalendar to compare
Returns:
this XMLGregorianCalendar normalized to UTC. the relationship between lhs and rhs as LESSER , EQUAL , GREATER or INDETERMINATE .
Throws:
NullPointerException - if lhs or rhs parameters are null.

equals

public boolean equals(Object obj)

Indicates whether parameter obj is "equal to" this one.

Overrides:
equals in class Object
Parameters:
obj - to compare.
Returns:
true when obj is an instance of XMLGregorianCalendar and compare(XMLGregorianCalendar obj) returns DatatypeConstants.EQUAL , otherwise false. true when compare(this,(XMLGregorianCalendar)obj) == EQUAL..
Throws:
NullPointerException - If obj is null.
See Also:
Object.hashCode() , Hashtable

hashCode

public int hashCode()

Returns a hash code consistent with the definition of the equals method.

Overrides:
hashCode in class Object
Returns:
hash code of this object.
See Also:
Object.equals(java.lang.Object) , Hashtable

parse


public static XMLGregorianCalendarparse ( 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.

Parameters:
lexicalRepresentation - Lexical representation of one the 8 XML Schema calendar datatypes.
Returns:
XMLGregorianCalendar created from parsing lexicalRepresentation parameter.
Throws:
IllegalArgumentException - If the given string does not conform to the aforementioned specification.
NullPointerException - If the given string is null.

toXMLFormat

public abstract 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() .

Returns:
XML, as String, representation of this XMLGregorianCalendar
Throws:
IllegalStateException - if the combination of set fields does not match one of the eight defined XML Schema builtin date/time datatypes.

getXMLSchemaType

public abstract 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 DATETIME X X X X X X
DatatypeConstants.DATE DATE X X X
DatatypeConstants.TIME TIME X X X
DatatypeConstants.GYEARMONTH GYEARMONTH X X
DatatypeConstants.GMONTHDAY GMONTHDAY X X
DatatypeConstants.GYEAR GYEAR X
DatatypeConstants.GMONTH GMONTH X
DatatypeConstants.GDAY GDAY X

Returns:
One of the following class constants: DatatypeConstants.DATETIME , DatatypeConstants.TIME , DatatypeConstants.DATE , DatatypeConstants.GYEARMONTH , DatatypeConstants.GMONTHDAY , DatatypeConstants.GYEAR , DatatypeConstants.GMONTH or DatatypeConstants.GDAY . one of the following class constants DATETIME, TIME, DATE, GYEARMONTH, GMONTHDAY, GYEAR, GMONTH or GDAY.
Throws:
IllegalStateException - if the combination of set fields does not match one of the eight defined XML Schema builtin date/time datatypes.

toString


public StringtoString () 

Return a human readable String representation of this XMLGregorianCalendar.

Overrides:
toString in class Object
Returns:
human readable String representation of this XMLGregorianCalendar.

isValid

public abstract boolean isValid()
Validate instance by getXMLSchemaType() constraints.

Returns:
true if data values are valid.

add

public abstract 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.

Parameters:
duration - Duration to add to this XMLGregorianCalendar.
Throws:
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.

toGregorianCalendar

public abstract GregorianCalendar toGregorianCalendar()

Convert this XMLGregorianCalendar to a GregorianCalendar . 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() < 0 ? GregorianCalendar.BC : GregorianCalendar.AD
YEAR getEonAndYear() *
MONTH getMonth() - DatatypeConstants.JANUARY + Calendar.JANUARY
MONTH getMonth()
DAY_OF_MONTH getDay()
HOUR_OF_DAY getHour()
AM_PM getHour() < 12 : Calendar.AM : Calendar.PM
MINUTE getMinute()
HOUR_OF_DAY getHour()
SECOND getSecond()
MINUTE getMinute()
MILLISECOND get millisecond order from getFractionalSecond() *
SECOND getSecond()
GregorianCalendar.setTimeZone(TimeZone) getTimezone()
MILLISECOND get millisecond order from getFractionalSecond() *
GregorianCalendar.setTimeZone(TimeZone) getTimezone()
* designates possible loss of precision during the conversion due to source datatype having higher precision higer precison than target datatype.

To ensure consistency in conversion implementations, the new GregorianCalendar should be instantiated in following manner.

  • Using timeZone value as defined above, create a new java.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:
toGregorianCalendar(java.util.TimeZone, java.util.Locale, XMLGregorianCalendar)

toGregorianCalendar

public abstract GregorianCalendar toGregorianCalendar(TimeZone timezone,
 Locale aLocale,
 XMLGregorianCalendar defaults)

Convert this XMLGregorianCalendar along with provided parameters to a GregorianCalendar 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,

  • when parameter timeZone is non-null, it is the timezone field.
  • else when this.getTimezone() != FIELD_UNDEFINED, create a java.util.TimeZone with a custom timezone id using the this.getTimezone().
  • else when defaults.getTimezone() != FIELD_UNDEFINED, create a java.util.TimeZone with a custom timezone id using defaults.getTimezone().
  • else use the GregorianCalendar default timezone value for the host is defined as definedas specified by java.util.TimeZone.getDefault().
  • To ensure consistency in conversion implementations, the new GregorianCalendar should be instantiated in following manner.

    • Create a new java.util.GregorianCalendar(TimeZone, Locale) with TimeZone set as specified above and the Locale parameter.
    • 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)

    Parameters:
    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.
    Returns:
    a java.util.GregorianCalendar conversion of this instance.
    See Also:
    LEAP_YEAR_DEFAULT

getTimeZone fromGregorianCalendar


public abstract TimeZone
public static XMLGregorianCalendar getTimeZone fromGregorianCalendar (int defaultZoneoffset) ( GregorianCalendar cal) 

Returns a java.util.TimeZone for this class. 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)

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). * 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,

  • when this.getTimezone() != FIELD_UNDEFINED, create a java.util.TimeZone with a custom timezone id using the this.getTimezone().
  • else use the GregorianCalendar default timezone value for the host is defined as specified by java.util.TimeZone.getDefault().
  • Parameters:
    defaultZoneoffset - default zoneoffset if this zoneoffset is DatatypeConstants.FIELD_UNDEFINED . cal - java.util.GregorianCalendar used to create XMLGregorianCalendar
    Returns:
    TimeZone for this. XMLGregorianCalendar created from java.util.GregorianCalendar

clone

public abstract Object clone()

Creates and returns a copy of this object.

Overrides:
clone in class Object
Returns:
copy of this Object
See Also:
Cloneable

clear


public void clear () 

Unset all fields to undefined.

Set all int fields to FIELD_UNDEFINED and reference fields to null.

Overrides:
clone in class Object
Returns:
copy of this Object
See Also:
Cloneable