Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
XMLGregorianCalendar
net.sf.saxon.xqj.SaxonXMLGregorianCalendar
public class SaxonXMLGregorianCalendar
extends XMLGregorianCalendar
CalendarValue
The JAXP specification for this class defines it in terms of XML Schema 1.0 semantics.
This implementation is more aligned to the XPath 2.0 semantics of the data types.
Note that this class, unlike the representations of all other data types, is mutable.
Constructor Summary | |
|
Method Summary | |
void |
|
void |
|
Object |
|
int |
|
int |
|
BigInteger |
|
BigInteger |
|
BigDecimal |
|
int |
|
int |
|
int |
|
int |
|
int |
|
TimeZone |
|
int |
|
QName |
|
int |
|
boolean |
|
XMLGregorianCalendar |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
CalendarValue |
|
GregorianCalendar |
|
GregorianCalendar |
|
String |
|
public SaxonXMLGregorianCalendar(CalendarValue value)
Create a SaxonXMLGregorianCalendar from a Saxon CalendarValue object
- Parameters:
value
- the CalendarValue
public void add(Duration duration)
Addduration
to this instance. 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.0dateTime
fields to this class' representation of those fields.
- Parameters:
duration
- Duration to add to thisXMLGregorianCalendar
.
public void clear()
Unset all fields to undefined. Set all int fields tojavax.xml.datatype.DatatypeConstants.FIELD_UNDEFINED
and reference fields to null.
public Object clone()
Creates and returns a copy of this object.
- Returns:
- copy of this
Object
public 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.xsd:dateTime
datatype field mapping to accessors of this class are defined in date/time field mapping table.
- Parameters:
xmlGregorianCalendar
- Instance ofXMLGregorianCalendar
to compare
- Returns:
- The relationship between
this
XMLGregorianCalendar
and the specifiedxmlGregorianCalendar
asjavax.xml.datatype.DatatypeConstants.LESSER
,javax.xml.datatype.DatatypeConstants.EQUAL
,javax.xml.datatype.DatatypeConstants.GREATER
orjavax.xml.datatype.DatatypeConstants.INDETERMINATE
.
public int getDay()
Return day in month orjavax.xml.datatype.DatatypeConstants.FIELD_UNDEFINED
. Value constraints for this value are summarized in day field of date/time field mapping table.
- See Also:
setDay(int)
public BigInteger getEon()
Return high order component for XML Schema 1.0 dateTime datatype field foryear
.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()
public BigInteger getEonAndYear()
Return XML Schema 1.0 dateTime datatype field foryear
. Value constraints for this value are summarized in year field of date/time field mapping table.
- Returns:
- sum of
eon
andBigInteger.valueOf(year)
when both fields are defined. When onlyyear
is defined, return it. When botheon
andyear
are not defined, returnnull
.
public BigDecimal getFractionalSecond()
Return fractional seconds.null
is returned when this optional field is not defined. Value constraints are detailed in second field of date/time field mapping table. This optional field can only have a defined value when the xs:dateTime second field, represented bygetSecond()
, does not returnjavax.xml.datatype.DatatypeConstants.FIELD_UNDEFINED
.
- Returns:
- fractional seconds of this
XMLGregorianCalendar
.
- See Also:
getSecond()
,setTime(int, int, int, java.math.BigDecimal)
public int getHour()
Return hours orjavax.xml.datatype.DatatypeConstants.FIELD_UNDEFINED
. Returnsjavax.xml.datatype.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.
- See Also:
setTime(int, int, int)
public int getMicrosecond()
Return microsecond precision ofgetFractionalSecond()
. This method represents a convenience accessor to infinite precision fractional second value returned bygetFractionalSecond()
. The returned value is the rounded down to microseconds 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
XMLGregorianCalendar
.
- See Also:
getFractionalSecond()
,setTime(int, int, int)
public int getMinute()
Return minutes orjavax.xml.datatype.DatatypeConstants.FIELD_UNDEFINED
. Returnsjavax.xml.datatype.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.
- See Also:
setTime(int, int, int)
public int getMonth()
Return number of month orjavax.xml.datatype.DatatypeConstants.FIELD_UNDEFINED
. Value constraints for this value are summarized in month field of date/time field mapping table.
- Returns:
- year of this
XMLGregorianCalendar
.
public int getSecond()
Return seconds orjavax.xml.datatype.DatatypeConstants.FIELD_UNDEFINED
. Returnsjavax.xml.datatype.DatatypeConstants.FIELD_UNDEFINED
if 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
XMLGregorianCalendar
.
- See Also:
getFractionalSecond()
,getMillisecond()
,setTime(int, int, int)
public TimeZone getTimeZone(int defaultZoneoffset)
Returns ajava.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).
- Parameters:
defaultZoneoffset
- default zoneoffset if this zoneoffset isjavax.xml.datatype.DatatypeConstants.FIELD_UNDEFINED
.
- Returns:
- TimeZone for this.
public int getTimezone()
Return timezone offset in minutes orjavax.xml.datatype.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.
- See Also:
setTimezone(int)
public QName getXMLSchemaType()
Return the name of the XML Schema date/time type that this instance maps to. Type is computed based on fields that are set.
- Returns:
- One of the following class constants:
javax.xml.datatype.DatatypeConstants.DATETIME
,javax.xml.datatype.DatatypeConstants.TIME
,javax.xml.datatype.DatatypeConstants.DATE
,javax.xml.datatype.DatatypeConstants.GYEARMONTH
,javax.xml.datatype.DatatypeConstants.GMONTHDAY
,javax.xml.datatype.DatatypeConstants.GYEAR
,javax.xml.datatype.DatatypeConstants.GMONTH
orjavax.xml.datatype.DatatypeConstants.GDAY
.
public int getYear()
Return low order component for XML Schema 1.0 dateTime datatype field foryear
orjavax.xml.datatype.DatatypeConstants.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()
public boolean isValid()
Validate instance bygetXMLSchemaType()
constraints.
- Returns:
- true if data values are valid.
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).
- Returns:
- a copy of this
XMLGregorianCalendar
normalized to UTC.
public void reset()
Reset thisXMLGregorianCalendar
to its original values.
public void setCalendarValue(CalendarValue value)
Set the calendar value of this object
- Parameters:
value
- the calendar value
public void setDay(int day)
Set days in month. Unset this field by invoking the setter with a parameter value ofjavax.xml.datatype.DatatypeConstants.FIELD_UNDEFINED
.
- Parameters:
day
- value constraints summarized in day field of date/time field mapping table.
public void setFractionalSecond(BigDecimal fractional)
Set fractional seconds. Unset this field by invoking the setter with a parameter value ofnull
.
- Parameters:
fractional
- value constraints summarized in fractional field of date/time field mapping table.
public void setHour(int hour)
Set hours. Unset this field by invoking the setter with a parameter value ofjavax.xml.datatype.DatatypeConstants.FIELD_UNDEFINED
.
- Parameters:
hour
- value constraints summarized in hour field of date/time field mapping table.
public void setMillisecond(int millisecond)
Set milliseconds. Unset this field by invoking the setter with a parameter value ofjavax.xml.datatype.DatatypeConstants.FIELD_UNDEFINED
.
- Parameters:
millisecond
- value constraints summarized in millisecond field of date/time field mapping table.
public void setMinute(int minute)
Set minutes. Unset this field by invoking the setter with a parameter value ofjavax.xml.datatype.DatatypeConstants.FIELD_UNDEFINED
.
- Parameters:
minute
- value constraints summarized in minute field of date/time field mapping table.
public void setMonth(int month)
Set month. Unset this field by invoking the setter with a parameter value ofjavax.xml.datatype.DatatypeConstants.FIELD_UNDEFINED
.
- Parameters:
month
- value constraints summarized in month field of date/time field mapping table.
public void setSecond(int second)
Set seconds. Unset this field by invoking the setter with a parameter value ofjavax.xml.datatype.DatatypeConstants.FIELD_UNDEFINED
.
- Parameters:
second
- value constraints summarized in second field of date/time field mapping table.
public void setTimezone(int offset)
Set the number of minutes in the timezone offset. Unset this field by invoking the setter with a parameter value ofjavax.xml.datatype.DatatypeConstants.FIELD_UNDEFINED
.
- Parameters:
offset
- value constraints summarized in timezone field of date/time field mapping table.
public void setYear(BigInteger year)
Set low and high order component of XSDdateTime
year field. Unset this field by invoking the setter with a parameter value ofnull
.
- Parameters:
year
- value constraints summarized in year field of date/time field mapping table.
public void setYear(int year)
Set year of XSDdateTime
year field. Unset this field by invoking the setter with a parameter value ofjavax.xml.datatype.DatatypeConstants.FIELD_UNDEFINED
. Note: if the absolute value of theyear
parameter is less than 10^9, the eon component of the XSD year field is set tonull
by this method.
- Parameters:
year
- value constraints are summarized in year field of date/time field mapping table. If year isjavax.xml.datatype.DatatypeConstants.FIELD_UNDEFINED
, then eon is set tonull
.
public CalendarValue toCalendarValue()
Convert this SaxonXMLGregorianCalendar to a Saxon CalendarValue object
- Returns:
- the corresponding CalendarValue
public GregorianCalendar toGregorianCalendar()
Convert thisXMLGregorianCalendar
to ajava.util.GregorianCalendar
. Whenthis
instance has an undefined field, this conversion relies on thejava.util.GregorianCalendar
default for its corresponding field. A notable difference between XML Schema 1.0 date/time datatypes andjava.util.GregorianCalendar
is 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 theTimeZone
instance, seetoGregorianCalendar(java.util.TimeZone, Locale, javax.xml.datatype.XMLGregorianCalendar)
.
- See Also:
toGregorianCalendar(java.util.TimeZone, java.util.Locale, javax.xml.datatype.XMLGregorianCalendar)
public GregorianCalendar toGregorianCalendar(TimeZone timezone, Locale aLocale, XMLGregorianCalendar defaults)
Convert thisXMLGregorianCalendar
along with provided parameters to ajava.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 withtimezone
parameter. To compute the return value'sTimeZone
field,
- when parameter
timeZone
is non-null, it is the timezone field.- else when
this.getTimezone() != FIELD_UNDEFINED
, create ajava.util.TimeZone
with a custom timezone id using thethis.getTimezone()
.- else when
defaults.getTimezone() != FIELD_UNDEFINED
, create ajava.util.TimeZone
with a custom timezone id usingdefaults.getTimezone()
.- else use the
GregorianCalendar
default timezone value for the host is defined as specified byjava.util.TimeZone.getDefault()
.GregorianCalendar
- Create a new
java.util.GregorianCalendar(TimeZone, Locale)
with TimeZone set as specified above and theLocale
parameter.- Initialize all GregorianCalendar fields by calling
java.util.GregorianCalendar.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 isnull
.defaults
- provide default field values to use when corresponding field for this instance is FIELD_UNDEFINED or null. Ifdefaults
isnull
or a field within the specifieddefaults
is undefined, just usejava.util.GregorianCalendar
defaults.
- Returns:
- a java.util.GregorianCalendar conversion of this instance.
public String toXMLFormat()
Return the lexical representation ofthis
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 bygetXMLSchemaType()
.
- Returns:
- XML, as
String
, representation of thisXMLGregorianCalendar