public abstract class XMLGregorianCalendar extends Object implements Cloneable
表示为W3C XML Schema 1日期/时间数据类型。具体而言,这些日期/时间数据类型DatatypeConstants.DATETIME
,DatatypeConstants.TIME
,DatatypeConstants.DATE
,DatatypeConstants.GYEARMONTH
,DatatypeConstants.GMONTHDAY
,DatatypeConstants.GYEAR
,DatatypeConstants.GMONTH
,和DatatypeConstants.GDAY
在XML命名空间"http://www.w3.org/2001/XMLSchema"
定义。这些数据类型的规范中定义的W3C XML Schema 1.0 Part 2, Section 3.2.7-14。
下表定义了XML Schema 1日期/时间数据类型的字段,这类的字段之间的映射。总结了价值约束的日期和时间字段中定义的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() + getEon() orgetEonAndYear() |
getYear() is a value between -(10^9-1) to (10^9)-1 or DatatypeConstants.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 |
day | getDay() |
Independent of month, max range is 1 to 31 or DatatypeConstants.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 23 or DatatypeConstants.FIELD_UNDEFINED . An hour value of 24 is allowed to be set in the lexical space provided the minute and second field values are zero. However, an hour value of 24 is not allowed in value space and will be transformed to represent the value of the first instance of the following day as per XML Schema Part 2: Datatypes Second Edition, 3.2 Primitive datatypes. |
minute | getMinute() |
0 to 59 or DatatypeConstants.FIELD_UNDEFINED |
second | getSecond() + getMillisecond() /1000 orgetSecond() + getFractionalSecond() |
getSecond() from 0 to 60 or DatatypeConstants.FIELD_UNDEFINED .(Note: 60 only allowable for leap second.) getFractionalSecond() allows for infinite precision over the range from 0.0 to 1.0 when the getSecond() is defined.FractionalSecond is optional and has a value of null when it is undefined.getMillisecond() is the convenience millisecond precision of value of getFractionalSecond() . |
timezone | getTimezone() |
Number of minutes or DatatypeConstants.FIELD_UNDEFINED . Value range from -14 hours (-14 * 60 minutes) to 14 hours (14 * 60 minutes). |
最大值空间限制上市上面表中的字段由工厂方法检查,“{链接datatypefactory },setter方法,这类方法解析。IllegalArgumentException
是当一个参数的值是在现场或者复合价值观构成了一个无效的xmlgregoriancalendar实例的值约束抛(例如,如果六月三十一日指定)。
下面的操作为这个类定义:
toString()
之间,DatatypeFactory.newXMLGregorianCalendar(String lexicalRepresentation)
GregorianCalendar
之间转换,toGregorianCalendar(java.util.TimeZone timezone, java.util.Locale aLocale, XMLGregorianCalendar defaults)
,DatatypeFactory
compare(XMLGregorianCalendar xmlGregorianCalendar)
equals(Object)
定义相对于compare(XMLGregorianCalendar xmlGregorianCalendar)
。Duration
实例中定义的 W3C XML Schema 1.0 Part 2, Appendix E, Adding durations to dateTimes加法运算。Duration
,
DatatypeFactory
Constructor and Description |
---|
XMLGregorianCalendar()
默认的无参数构造函数。
|
Modifier and Type | Method and Description |
---|---|
abstract void |
add(Duration duration)
添加
duration 这个实例。
|
abstract void |
clear()
消除所有字段定义。
|
abstract Object |
clone()
创建并返回此对象的副本。
|
abstract int |
compare(XMLGregorianCalendar xmlGregorianCalendar)
比较两个实例的W3C XML Schema 1日期/时间数据类型根据偏序关系定义在
W3C XML Schema 1.0 Part 2, Section 3.2.7.3, Order relation on dateTime。
|
boolean |
equals(Object obj)
将此日历与指定的对象进行比较。
|
abstract int |
getDay()
|
abstract BigInteger |
getEon()
返回的XML Schema 1日期时间数据类型字段
year 高阶分量。
|
abstract BigInteger |
getEonAndYear()
返回的XML Schema 1日期时间数据类型字段
year 。
|
abstract BigDecimal |
getFractionalSecond()
返回分数秒。
|
abstract int |
getHour()
|
int |
getMillisecond()
对
getFractionalSecond() 返回毫秒精度。
|
abstract int |
getMinute()
|
abstract int |
getMonth()
|
abstract int |
getSecond()
|
abstract int |
getTimezone()
返回时区偏移在几分钟或
DatatypeConstants.FIELD_UNDEFINED 如果这个字段没有定义。
|
abstract TimeZone |
getTimeZone(int defaultZoneoffset)
返回该类
java.util.TimeZone 。
|
abstract QName |
getXMLSchemaType()
返回此实例映射到的XML模式日期/时间类型的名称。
|
abstract int |
getYear()
返回的XML Schema 1日期时间数据类型字段
year 或
DatatypeConstants.FIELD_UNDEFINED 低阶分量。
|
int |
hashCode()
返回与等于方法的定义一致的哈希代码。
|
abstract boolean |
isValid()
通过
getXMLSchemaType() 约束验证实例。
|
abstract XMLGregorianCalendar |
normalize()
规范此实例时。
|
abstract void |
reset()
这
XMLGregorianCalendar 复位到其原始值。
|
abstract void |
setDay(int day)
月定天数。
|
abstract void |
setFractionalSecond(BigDecimal fractional)
设置分数秒。
|
abstract void |
setHour(int hour)
设置时间。
|
abstract void |
setMillisecond(int millisecond)
设置毫秒。
|
abstract void |
setMinute(int minute)
设置分钟。
|
abstract void |
setMonth(int month)
月设定。
|
abstract void |
setSecond(int second)
设置秒。
|
void |
setTime(int hour, int minute, int second)
设置时间为一个单位。
|
void |
setTime(int hour, int minute, int second, BigDecimal fractional)
设置时间为一个单位,包括可选的无限精密分数秒。
|
void |
setTime(int hour, int minute, int second, int millisecond)
设置时间为一个单位,包括可选的毫秒。
|
abstract void |
setTimezone(int offset)
集数分钟的时区偏移量。
|
abstract void |
setYear(BigInteger year)
设置低和XSD
dateTime 年场高阶分量。
|
abstract void |
setYear(int year)
XSD
dateTime 年场年。
|
abstract GregorianCalendar |
toGregorianCalendar()
将这一
GregorianCalendar
XMLGregorianCalendar 。
|
abstract GregorianCalendar |
toGregorianCalendar(TimeZone timezone, Locale aLocale, XMLGregorianCalendar defaults)
把这
XMLGregorianCalendar 随着提供的参数为
GregorianCalendar 实例。
|
String |
toString()
返回该
XMLGregorianCalendar
Object 一
String 表示。
|
abstract String |
toXMLFormat()
返回
this 实例的词汇表征。
|
public XMLGregorianCalendar()
注:总是用DatatypeFactory
构建XMLGregorianCalendar
实例。这类的构造函数不能保证生产一致性状态的对象和未来可能会删除。
public abstract void clear()
消除所有字段定义。
设置所有的int字段DatatypeConstants.FIELD_UNDEFINED
和参考字段为空。
public abstract void reset()
这XMLGregorianCalendar
复位到其原始值。
XMLGregorianCalendar
设置为相同的值时DatatypeFactory.newXMLGregorianCalendar()
,DatatypeFactory.newXMLGregorianCalendar(String lexicalRepresentation)
,DatatypeFactory.newXMLGregorianCalendar( BigInteger year, int month, int day, int hour, int minute, int second, BigDecimal fractionalSecond, int timezone)
,DatatypeFactory.newXMLGregorianCalendar( int year, int month, int day, int hour, int minute, int second, int millisecond, int timezone)
,DatatypeFactory.newXMLGregorianCalendar(GregorianCalendar cal)
,DatatypeFactory.newXMLGregorianCalendarDate( int year, int month, int day, int timezone)
,DatatypeFactory.newXMLGregorianCalendarTime( int hours, int minutes, int seconds, int timezone)
创建,DatatypeFactory.newXMLGregorianCalendarTime( int hours, int minutes, int seconds, BigDecimal fractionalSecond, int timezone)
或DatatypeFactory.newXMLGregorianCalendarTime( int hours, int minutes, int seconds, int milliseconds, int timezone)
。
reset()
旨在让现有的XMLGregorianCalendar
s节约与新XMLGregorianCalendar
s创作相关资源的重用。
public abstract void setYear(BigInteger year)
设置低和XSD dateTime
年场高阶分量。
取消这场通过调用setter和null
参数值。
year
值限制了
year field of date/time field mapping table。
IllegalArgumentException
-如果
year
参数以外的字段值的约束中指定的
date/time field mapping table。
public abstract void setYear(int year)
XSD dateTime
年场年。
取消这场通过调用setter和DatatypeConstants.FIELD_UNDEFINED
参数值。
注意:如果在year
参数的绝对值小于9的10 ^,XSD年场EON组件设置null
通过这种方法。
year
值约束进行了
year field of date/time field mapping table。如果今年
DatatypeConstants.FIELD_UNDEFINED
,然后将
null
EON。
public abstract void setMonth(int month)
月设定。
取消这场通过调用setter和DatatypeConstants.FIELD_UNDEFINED
参数值。
month
值限制了
month field of date/time field mapping table。
IllegalArgumentException
-如果
month
参数以外的字段值的约束中指定的
date/time field mapping table。
public abstract void setDay(int day)
月定天数。
取消这场通过调用setter和DatatypeConstants.FIELD_UNDEFINED
参数值。
day
值限制了
day field of date/time field mapping table。
IllegalArgumentException
-如果
day
参数以外的字段值的约束中指定的
date/time field mapping table。
public abstract void setTimezone(int offset)
集数分钟的时区偏移量。
取消这场通过调用setter和DatatypeConstants.FIELD_UNDEFINED
参数值。
offset
值限制了
timezone field of date/time field mapping table。
IllegalArgumentException
-如果
offset
参数以外的字段值的约束中指定的
date/time field mapping table。
public void setTime(int hour, int minute, int second)
设置时间为一个单位。
hour
值约束进行了
hour field of date/time field mapping table。
minute
值约束进行了
minute field of date/time field mapping table。
second
值约束进行了
second field of date/time field mapping table。
IllegalArgumentException
-如果任何参数以外的字段值的约束中指定的
date/time field mapping table。
setTime(int, int, int, BigDecimal)
public abstract void setHour(int hour)
设置时间。
取消这场通过调用setter和DatatypeConstants.FIELD_UNDEFINED
参数值。
hour
值限制了
hour field of date/time field mapping table。
IllegalArgumentException
-如果
hour
参数以外的字段值的约束中指定的
date/time field mapping table。
public abstract void setMinute(int minute)
设置分钟。
取消这场通过调用setter和DatatypeConstants.FIELD_UNDEFINED
参数值。
minute
值限制了
minute field of date/time field mapping table。
IllegalArgumentException
-如果
minute
参数以外的字段值的约束中指定的
date/time field mapping table。
public abstract void setSecond(int second)
设置秒。
取消这场通过调用setter和DatatypeConstants.FIELD_UNDEFINED
参数值。
second
值限制了
second field of date/time field mapping table。
IllegalArgumentException
-如果
second
参数以外的字段值的约束中指定的
date/time field mapping table。
public abstract void setMillisecond(int millisecond)
设置毫秒。
取消这场通过调用setter和DatatypeConstants.FIELD_UNDEFINED
参数值。
millisecond
值限制了
second field of date/time field mapping table。
IllegalArgumentException
-如果
millisecond
参数以外的字段值的约束中指定的
date/time field mapping table。
public abstract void setFractionalSecond(BigDecimal fractional)
设置分数秒。
取消这场通过调用setter和null
参数值。
fractional
值限制了
second field of date/time field mapping table。
IllegalArgumentException
-如果
fractional
参数以外的字段值的约束中指定的
date/time field mapping table。
public void setTime(int hour, int minute, int second, BigDecimal fractional)
设置时间为一个单位,包括可选的无限精密分数秒。
hour
值约束进行了
hour field of date/time field mapping table。
minute
值约束进行了
minute field of date/time field mapping table。
second
值约束进行了
second field of date/time field mapping table。
fractional
值
null
表示未设置此可选字段。
IllegalArgumentException
-如果任何参数以外的字段值的约束中指定的
date/time field mapping table。
public void setTime(int hour, int minute, int second, int millisecond)
设置时间为一个单位,包括可选的毫秒。
hour
值约束进行了
hour field of date/time field mapping table。
minute
值约束进行了
minute field of date/time field mapping table。
second
值约束进行了
second field of date/time field mapping table。
millisecond
值
DatatypeConstants.FIELD_UNDEFINED
表示未设置此可选字段。
IllegalArgumentException
-如果任何参数以外的字段值的约束中指定的
date/time field mapping table。
public abstract BigInteger getEon()
返回的XML Schema datetime数据类型year
1场高阶分量。如果这一年的null
可选字段部分未定义。
XMLGregorianCalendar
。返回的值是10的整数倍^ 9。
getYear()
,
getEonAndYear()
public abstract int getYear()
返回的XML Schema 1日期时间数据类型字段year
或DatatypeConstants.FIELD_UNDEFINED
低阶分量。
XMLGregorianCalendar
年。
getEon()
,
getEonAndYear()
public abstract BigInteger getEonAndYear()
返回的XML Schema 1日期时间数据类型字段year
。
public abstract int getMonth()
XMLGregorianCalendar
年。
public abstract int getDay()
setDay(int)
public abstract int getTimezone()
DatatypeConstants.FIELD_UNDEFINED
如果这个字段没有定义。
setTimezone(int)
public abstract int getHour()
DatatypeConstants.FIELD_UNDEFINED
。返回
DatatypeConstants.FIELD_UNDEFINED
如果这个字段没有定义。
setTime(int, int, int)
public abstract int getMinute()
DatatypeConstants.FIELD_UNDEFINED
。
返回
DatatypeConstants.FIELD_UNDEFINED
如果这个字段没有定义。
setTime(int, int, int)
public abstract int getSecond()
返回秒或DatatypeConstants.FIELD_UNDEFINED
。
返回DatatypeConstants.FIELD_UNDEFINED
如果这个字段没有定义。当这场是没有定义的,可选的XS:datetime小数秒的领域,通过getFractionalSecond()
和getMillisecond()
表示,不能确定。
XMLGregorianCalendar
二。
getFractionalSecond()
,
getMillisecond()
,
setTime(int, int, int)
public int getMillisecond()
对getFractionalSecond()
返回毫秒精度。
这种方法是一种方便的访问到无限精度小数秒的返回值getFractionalSecond()
。返回值是圆形的到getFractionalSecond()
毫秒值。当getFractionalSecond()
返回null
,这个方法必须返回DatatypeConstants.FIELD_UNDEFINED
。
XMLGregorianCalendar
毫秒。
getFractionalSecond()
,
setTime(int, int, int)
public abstract BigDecimal getFractionalSecond()
返回分数秒。
null
时返回此可选字段没有定义。
价值的详细约束在second field of date/time field mapping table。
本字段只能有一个明确的价值当xs:日期时间第二场,由getSecond()
,不返回DatatypeConstants.FIELD_UNDEFINED
。
XMLGregorianCalendar
分数秒。
getSecond()
,
setTime(int, int, int, BigDecimal)
public abstract int compare(XMLGregorianCalendar xmlGregorianCalendar)
比较两个实例的W3C XML Schema 1日期/时间数据类型根据偏序关系定义在W3C XML Schema 1.0 Part 2, Section 3.2.7.3, Order relation on dateTime。
xsd:dateTime
数据类型的字段映射到该类的访问器定义在date/time field mapping table。
xmlGregorianCalendar
实例的
XMLGregorianCalendar
比较
this
XMLGregorianCalendar
和指定的
xmlGregorianCalendar
作为
DatatypeConstants.LESSER
,
DatatypeConstants.EQUAL
之间的关系,
DatatypeConstants.GREATER
或
DatatypeConstants.INDETERMINATE
。
NullPointerException
-如果
xmlGregorianCalendar
是空的。
public abstract XMLGregorianCalendar normalize()
规范此实例时。
2000-03-04t23:00:00 +规范化2000-03-04t20:00:00z 03:00
实现了W3C XML Schema部分2、部分3.2.7.3(一)。
this
XMLGregorianCalendar
归一化UTC。
public boolean equals(Object obj)
将此日历与指定的对象进行比较。其结果是true
当且仅当参数不为空,是一个XMLGregorianCalendar
表示在时间这个对象的一瞬间。
equals
方法重写,继承类
Object
obj
-比较。
true
当
obj
是
XMLGregorianCalendar
和
compare(XMLGregorianCalendar obj)
返回
DatatypeConstants.EQUAL
实例,否则
false
。
Object.hashCode()
,
HashMap
public int hashCode()
返回与等于方法的定义一致的哈希代码。
hashCode
方法重写,继承类
Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
public abstract String toXMLFormat()
返回this
实例的词汇表征。格式是指定在XML Schema 1.0 Part 2, Section 3.2.[7-14].1, Lexical Representation".
具体的目标词汇表示格式是由getXMLSchemaType()
。
String
,这
XMLGregorianCalendar
表示
IllegalStateException
-如果设置字段的组合不匹配的八个定义的XML架构内置的日期/时间数据类型。
public abstract QName getXMLSchemaType()
返回此实例映射到的XML模式日期/时间类型的名称。类型是基于设置的字段计算的。
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 |
DatatypeConstants.DATETIME
,
DatatypeConstants.TIME
,
DatatypeConstants.DATE
,
DatatypeConstants.GYEARMONTH
,
DatatypeConstants.GMONTHDAY
,
DatatypeConstants.GYEAR
,
DatatypeConstants.GMONTH
或
DatatypeConstants.GDAY
。
IllegalStateException
-如果设置字段的组合不匹配的八个定义的XML架构内置的日期/时间数据类型。
public String toString()
返回该XMLGregorianCalendar
Object
一String
表示。
其结果是一个词汇表征所产生的toXMLFormat()
。
toString
方法重写,继承类
Object
null
有效
String
表示这
XMLGregorianCalendar
。
IllegalStateException
-如果设置字段的组合不匹配的八个定义的XML架构内置的日期/时间数据类型。
toXMLFormat()
public abstract boolean isValid()
getXMLSchemaType()
约束验证实例。
public abstract void add(Duration duration)
添加duration
这个实例。
计算指定在XML Schema 1.0 Part 2, Appendix E, Adding durations to dateTimes>。date/time field mapping table定义映射的XML Schema 1 dateTime
领域,这些领域这类的表示。
duration
时间添加到这
XMLGregorianCalendar
。
NullPointerException
当
duration
参数
null
。
public abstract GregorianCalendar toGregorianCalendar()
将这一GregorianCalendar
XMLGregorianCalendar
。
当this
实例具有一个未定义的领域,这一转换依赖于其相应的领域java.util.GregorianCalendar
默认。XML Schema 1日期/时间数据类型和java.util.GregorianCalendar
之间的显著区别是时区值为日期/时间数据类型,它是java.util.GregorianCalendar
必填字段可选。看javadoc java.util.TimeZone.getDefault()
如何预设确定。显式地指定TimeZone
实例,看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 |
为保证转换实现的一致性,新的GregorianCalendar
应该实例化方式如下。
timeZone
值如上定义,创建一个新的java.util.GregorianCalendar(timeZone,Locale.getDefault())
。Calendar.clear()
公历。GregorianCalendar.setGregorianChange( new Date(Long.MIN_VALUE))
获得纯阳历。Calendar.set(int,int)
public abstract GregorianCalendar toGregorianCalendar(TimeZone timezone, Locale aLocale, XMLGregorianCalendar defaults)
把这XMLGregorianCalendar
随着提供的参数为GregorianCalendar
实例。
由于XML Schema 1日期/时间datetypes没有时区标识或夏令时区IDS的概念,这个转换操作允许用户显式地指定一个timezone
参数。
计算返回值的TimeZone
场,
timeZone
非空,它是时区的领域。this.getTimezone() != FIELD_UNDEFINED
,创建一个使用this.getTimezone()
自定义时区ID java.util.TimeZone
。defaults.getTimezone() != FIELD_UNDEFINED
,创建一个使用defaults.getTimezone()
自定义时区ID java.util.TimeZone
。GregorianCalendar
默认时区值为主机定义为指定的java.util.TimeZone.getDefault()
。为保证转换实现的一致性,新的GregorianCalendar
应该实例化方式如下。
java.util.GregorianCalendar(TimeZone, Locale)
与时区设置为指定的上述Locale
参数。Calendar.clear()
公历GregorianCalendar.setGregorianChange( new Date(Long.MIN_VALUE))
获得纯阳历。Calendar.set(int,int)
timezone
提供时区。
null
是法律价值。
aLocale
提供明确的现场。如果使用默认值
null
公历现场。
defaults
提供默认字段值时要使用的相应字段的这个实例是field_undefined或空。如果在指定的
defaults
defaults
is
null
或一场是未定义的,只是用
java.util.GregorianCalendar
违约。
public abstract TimeZone getTimeZone(int defaultZoneoffset)
返回该类java.util.TimeZone
。
如果时区领域是该实例的定义,返回时区与时区ID zoneoffset自定义初始化。如果时区字段定义,尝试defaultzoneoffset,通过。如果defaultzoneoffset是field_undefined,此主机返回的默认时区。(如java,util。GregorianCalendar相同的默认)。
defaultZoneoffset
违约zoneoffset如果这zoneoffset是
DatatypeConstants.FIELD_UNDEFINED
。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.