public class ImmutableXMLGregorianCalendar extends XMLGregorianCalendar
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.
Constructor and Description |
---|
ImmutableXMLGregorianCalendar(XMLGregorianCalendar xc)
Constructs the immutable XMLGregorianCalendar instance, cloning the parameter.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Duration duration) |
void |
clear() |
ImmutableXMLGregorianCalendar |
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.
|
boolean |
equals(Object obj)
Compares this calendar to the specified object.
|
int |
getDay()
Return day in month or
DatatypeConstants.FIELD_UNDEFINED . |
BigInteger |
getEon()
Return high order component for XML Schema 1.0 dateTime datatype field for
year . |
BigInteger |
getEonAndYear()
Return XML Schema 1.0 dateTime datatype field for
year . |
BigDecimal |
getFractionalSecond()
Return fractional seconds.
|
int |
getHour()
Return hours or
DatatypeConstants.FIELD_UNDEFINED . |
int |
getMillisecond()
Return millisecond precision of
getFractionalSecond() . |
int |
getMinute()
Return minutes or
DatatypeConstants.FIELD_UNDEFINED . |
int |
getMonth()
Return number of month or
DatatypeConstants.FIELD_UNDEFINED . |
int |
getSecond()
Return seconds or
DatatypeConstants.FIELD_UNDEFINED . |
int |
getTimezone()
Return timezone offset in minutes or
DatatypeConstants.FIELD_UNDEFINED if this optional field is not
defined. |
TimeZone |
getTimeZone(int defaultZoneoffset)
Returns a
java.util.TimeZone for this class. |
QName |
getXMLSchemaType()
Return the name of the XML Schema date/time type that this instance maps
to.
|
int |
getYear()
Return low order component for XML Schema 1.0 dateTime datatype field for
year or DatatypeConstants.FIELD_UNDEFINED . |
int |
hashCode()
Returns a hash code consistent with the definition of the equals method.
|
boolean |
isValid()
Validate instance by
getXMLSchemaType() constraints. |
XMLGregorianCalendar |
normalize()
Normalize this instance to UTC.
|
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(BigInteger year) |
void |
setYear(int year) |
GregorianCalendar |
toGregorianCalendar()
Convert this
XMLGregorianCalendar to a
GregorianCalendar . |
GregorianCalendar |
toGregorianCalendar(TimeZone timezone,
Locale aLocale,
XMLGregorianCalendar defaults)
Convert this
XMLGregorianCalendar along with provided
parameters to a GregorianCalendar instance. |
String |
toString()
Returns a
String representation of this
XMLGregorianCalendar Object . |
String |
toXMLFormat()
Return the lexical representation of
this instance. |
String |
toXMLFormat(QName datatype)
Formats the string in XML for the datatype if possible.
|
setTime, setTime, setTime
public ImmutableXMLGregorianCalendar(XMLGregorianCalendar xc)
xc
- The mutable XMLGregorianCalendar instance.public ImmutableXMLGregorianCalendar clone()
clone
in class XMLGregorianCalendar
public BigInteger getEon()
year
. null
if this optional part of the year
field is not defined.
Value constraints for this value are summarized in year field of date/time field mapping table.
getEon
in class XMLGregorianCalendar
XMLGregorianCalendar
. The value returned
is an integer multiple of 10^9.getYear()
,
getEonAndYear()
public int getYear()
year
or DatatypeConstants.FIELD_UNDEFINED
.
Value constraints for this value are summarized in year field of date/time field mapping table.
getYear
in class XMLGregorianCalendar
XMLGregorianCalendar
.getEon()
,
getEonAndYear()
public BigInteger getEonAndYear()
year
.
Value constraints for this value are summarized in year field of date/time field mapping table.
getEonAndYear
in class XMLGregorianCalendar
eon
and BigInteger.valueOf(year)
when both fields are defined. When only year
is
defined, return it. When both eon
and
year
are not defined, return null
.getEon()
,
getYear()
public int getMonth()
DatatypeConstants.FIELD_UNDEFINED
.
Value constraints for this value are summarized in month field of date/time field mapping table.
getMonth
in class XMLGregorianCalendar
XMLGregorianCalendar
.public int getDay()
DatatypeConstants.FIELD_UNDEFINED
.
Value constraints for this value are summarized in day field of date/time field mapping table.
getDay
in class XMLGregorianCalendar
public int getTimezone()
DatatypeConstants.FIELD_UNDEFINED
if this optional field is not
defined.
Value constraints for this value are summarized in timezone field of date/time field mapping table.
getTimezone
in class XMLGregorianCalendar
public int getHour()
DatatypeConstants.FIELD_UNDEFINED
.
Returns DatatypeConstants.FIELD_UNDEFINED
if this field is not defined.
Value constraints for this value are summarized in hour field of date/time field mapping table.
getHour
in class XMLGregorianCalendar
public int getMinute()
DatatypeConstants.FIELD_UNDEFINED
.
Returns DatatypeConstants.FIELD_UNDEFINED
if this field is not defined.
Value constraints for this value are summarized in minute field of date/time field mapping table.
getMinute
in class XMLGregorianCalendar
public int getSecond()
DatatypeConstants.FIELD_UNDEFINED
.
Returns DatatypeConstants.FIELD_UNDEFINED
if this field is not
defined. When this field is not defined, the optional xs:dateTime
fractional seconds field, represented by getFractionalSecond()
and
getMillisecond()
, must not be defined.
Value constraints for this value are summarized in second field of date/time field mapping table.
getSecond
in class XMLGregorianCalendar
XMLGregorianCalendar
.getFractionalSecond()
,
getMillisecond()
public int getMillisecond()
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.
getMillisecond
in class XMLGregorianCalendar
XMLGregorianCalendar
.getFractionalSecond()
public BigDecimal getFractionalSecond()
null
is returned when this optional field is not defined.
Value constraints are detailed in second field of date/time field mapping table.
This optional field can only have a defined value when the xs:dateTime
second field, represented by getSecond()
, does not return
DatatypeConstants.FIELD_UNDEFINED
.
getFractionalSecond
in class XMLGregorianCalendar
XMLGregorianCalendar
.getSecond()
public int compare(XMLGregorianCalendar xmlGregorianCalendar)
xsd:dateTime
datatype field mapping to accessors of this class
are defined in date/time field mapping
table.
compare
in class XMLGregorianCalendar
xmlGregorianCalendar
- Instance of XMLGregorianCalendar
to comparethis
XMLGregorianCalendar
and the specified
xmlGregorianCalendar
as
DatatypeConstants.LESSER
, DatatypeConstants.EQUAL
,
DatatypeConstants.GREATER
or
DatatypeConstants.INDETERMINATE
.NullPointerException
- if xmlGregorianCalendar
is null.public boolean equals(Object obj)
true
if and only if the argument is not null and is an
XMLGregorianCalendar
object that represents the same instant
in time as this object.equals
in class XMLGregorianCalendar
obj
- to compare.true
when obj
is an instance of
XMLGregorianCalendar
and
compare(XMLGregorianCalendar obj)
returns
DatatypeConstants.EQUAL
, otherwise false
.public int hashCode()
hashCode
in class XMLGregorianCalendar
public String toXMLFormat()
this
instance. The format
is specified in XML Schema 1.0 Part
2, Section 3.2.[7-14].1, Lexical Representation".
Specific target lexical representation format is determined by
getXMLSchemaType()
.
toXMLFormat
in class XMLGregorianCalendar
String
, representation of this
XMLGregorianCalendar
IllegalStateException
- if the combination of set fields does not match one of the eight
defined XML Schema builtin date/time datatypes.public QName getXMLSchemaType()
Required fields for XML Schema 1.0 Date/Time Datatypes.
(timezone is optional for all date/time datatypes) |
||||||
---|---|---|---|---|---|---|
Datatype | year | month | day | hour | minute | second |
DatatypeConstants.DATETIME |
X | X | X | X | X | X |
DatatypeConstants.DATE |
X | X | X | |||
DatatypeConstants.TIME |
X | X | X | |||
DatatypeConstants.GYEARMONTH |
X | X | ||||
DatatypeConstants.GMONTHDAY |
X | X | ||||
DatatypeConstants.GYEAR |
X | |||||
DatatypeConstants.GMONTH |
X | |||||
DatatypeConstants.GDAY |
X |
getXMLSchemaType
in class XMLGregorianCalendar
DatatypeConstants.DATETIME
, DatatypeConstants.TIME
,
DatatypeConstants.DATE
,
DatatypeConstants.GYEARMONTH
,
DatatypeConstants.GMONTHDAY
,
DatatypeConstants.GYEAR
, DatatypeConstants.GMONTH
or DatatypeConstants.GDAY
.IllegalStateException
- if the combination of set fields does not match one of the eight
defined XML Schema builtin date/time datatypes.public String toString()
String
representation of this
XMLGregorianCalendar
Object
.
The result is a lexical representation generated by toXMLFormat()
.
toString
in class XMLGregorianCalendar
null
valid String
representation of
this XMLGregorianCalendar
.IllegalStateException
- if the combination of set fields does not match one of the eight
defined XML Schema builtin date/time datatypes.toXMLFormat()
public boolean isValid()
getXMLSchemaType()
constraints.isValid
in class XMLGregorianCalendar
public GregorianCalendar toGregorianCalendar()
XMLGregorianCalendar
to a
GregorianCalendar
.
When this
instance has an undefined field, this conversion
relies on the java.util.GregorianCalendar
default for its
corresponding field. A notable difference between XML Schema 1.0 date/time
datatypes and java.util.GregorianCalendar
is that Timezone
value is optional for date/time datatypes and it is a required field for
java.util.GregorianCalendar
. See javadoc for
java.util.TimeZone.getDefault()
on how the default is
determined. To explicitly specify the TimeZone
instance, see
toGregorianCalendar(TimeZone, Locale, XMLGregorianCalendar)
.
Field by Field Conversion from this class to
java.util.GregorianCalendar | |
---|---|
java.util.GregorianCalendar field |
javax.xml.datatype.XMLGregorianCalendar field |
ERA |
getEonAndYear()
.signum() < 0 ? GregorianCalendar.BC : GregorianCalendar.AD |
YEAR |
getEonAndYear() .abs().intValue() * |
MONTH |
getMonth() - 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
GregorianCalendar
should be instantiated in following manner.
timeZone
value as defined above, create a new
java.util.GregorianCalendar(timeZone,Locale.getDefault())
.Calendar.clear()
.GregorianCalendar.setGregorianChange(
new Date(Long.MIN_VALUE))
.Calendar.set(int,int)
toGregorianCalendar
in class XMLGregorianCalendar
toGregorianCalendar(java.util.TimeZone, java.util.Locale,
XMLGregorianCalendar)
public GregorianCalendar toGregorianCalendar(TimeZone timezone, Locale aLocale, XMLGregorianCalendar defaults)
XMLGregorianCalendar
along with provided
parameters to a GregorianCalendar
instance.
Since XML Schema 1.0 date/time datetypes has no concept of timezone ids or
daylight savings timezone ids, this conversion operation allows the user to
explicitly specify one with timezone
parameter.
To compute the return value's TimeZone
field,
timeZone
is non-null, it is the timezone
field.this.getTimezone() != FIELD_UNDEFINED
, create a
java.util.TimeZone
with a custom timezone id using the
this.getTimezone()
.defaults.getTimezone() != FIELD_UNDEFINED
,
create a java.util.TimeZone
with a custom timezone id using
defaults.getTimezone()
.GregorianCalendar
default timezone value for
the host is defined as specified by
java.util.TimeZone.getDefault()
.To ensure consistency in conversion implementations, the new
GregorianCalendar
should be instantiated in following manner.
java.util.GregorianCalendar(TimeZone,
Locale)
with TimeZone set as specified above and the
Locale
parameter.Calendar.clear()
GregorianCalendar.setGregorianChange(
new Date(Long.MIN_VALUE))
.Calendar.set(int,int)
toGregorianCalendar
in class XMLGregorianCalendar
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 defaults
is null
or a field within the specified
defaults
is undefined, just use
java.util.GregorianCalendar
defaults.public TimeZone getTimeZone(int defaultZoneoffset)
java.util.TimeZone
for this class.
If timezone field is defined for this instance, returns TimeZone initialized with custom timezone id of zoneoffset. If timezone field is undefined, try the defaultZoneoffset that was passed in. If defaultZoneoffset is FIELD_UNDEFINED, return default timezone for this host. (Same default as java.util.GregorianCalendar).
getTimeZone
in class XMLGregorianCalendar
defaultZoneoffset
- default zoneoffset if this zoneoffset is
DatatypeConstants.FIELD_UNDEFINED
.public String toXMLFormat(QName datatype) throws IllegalArgumentException, IllegalStateException
datatype
- The XML date/time datatype.IllegalArgumentException
- If the datatypeIllegalStateException
- If the combination of set fields does not match one of
the eight defined XML Schema built-in date/time datatypes.public void clear()
clear
in class XMLGregorianCalendar
public void reset()
reset
in class XMLGregorianCalendar
public void setYear(BigInteger year)
setYear
in class XMLGregorianCalendar
public void setYear(int year)
setYear
in class XMLGregorianCalendar
public void setMonth(int month)
setMonth
in class XMLGregorianCalendar
public void setDay(int day)
setDay
in class XMLGregorianCalendar
public void setTimezone(int offset)
setTimezone
in class XMLGregorianCalendar
public void setHour(int hour)
setHour
in class XMLGregorianCalendar
public void setMinute(int minute)
setMinute
in class XMLGregorianCalendar
public void setSecond(int second)
setSecond
in class XMLGregorianCalendar
public void setMillisecond(int millisecond)
setMillisecond
in class XMLGregorianCalendar
public void setFractionalSecond(BigDecimal fractional)
setFractionalSecond
in class XMLGregorianCalendar
public void add(Duration duration)
add
in class XMLGregorianCalendar
public XMLGregorianCalendar normalize()
Normalize this instance to UTC.
2000-03-04T23:00:00+03:00 normalizes to 2000-03-04T20:00:00Z
Implements W3C XML Schema Part 2, Section 3.2.7.3 (A).
normalize
in class XMLGregorianCalendar
clone()
'd instance of XMLGregorianCalendar
normalized to UTC.iizi® is a registered trademark of Mindus SARL. © Copyright 2019 Mindus SARL. All rights reserved.