JavaTM 2 Platform
Standard Ed. 6

javax.xml.datatype
類別 DatatypeFactory

java.lang.Object
  繼承者 javax.xml.datatype.DatatypeFactory

public abstract class DatatypeFactory
extends Object

創建新 javax.xml.datatype Object 的處理器,創建的物件可提供 XML 和 Java Object 之間的映射。

newInstance() 用於創建新的 DatatypeFactory。按下列順序使用以下實作解析機制:

  1. 如果 DATATYPEFACTORY_PROPERTY 指定的系統屬性 "javax.xml.datatype.DatatypeFactory" 存在,則實例化具有屬性值名稱的類別。將實例化進程中拋出的任何異常包裹為 DatatypeConfigurationException
  2. 如果檔案 ${JAVA_HOME}/lib/jaxp.properties 存在,則在 Properties Object 中載入它。然後查詢 Properties Object,以獲取前面步驟中的文檔介紹的屬性,並按照前面步驟中文檔的介紹進行處理。
  3. 使用服務解析機制,例如 META-INF/services/java.xml.datatype.DatatypeFactory。將實例化進程中拋出的任何異常包裹為 DatatypeConfigurationException
  4. 最終機制將嘗試實例化 DATATYPEFACTORY_IMPLEMENTATION_CLASS 指定的 Class。實例化進程中拋出的任何異常將被包裹為 DatatypeConfigurationException

從以下版本開始:
1.5

欄位摘要
static String DATATYPEFACTORY_IMPLEMENTATION_CLASS
          JSR 206: Java(TM) API for XML Processing (JAXP) 1.3 中定義的預設實作類別名稱。
static String DATATYPEFACTORY_PROPERTY
          JSR 206:Java(TM) API for XML Processing (JAXP) 1.3 中定義的預設實作類別名稱。
 
建構子摘要
protected DatatypeFactory()
          受保護的建構子,包外無法實例化。
 
方法摘要
abstract  Duration newDuration(boolean isPositive, BigInteger years, BigInteger months, BigInteger days, BigInteger hours, BigInteger minutes, BigDecimal seconds)
          獲取 Duration 的新實例,該 Duration 根據 isPositive、years、months、days、hours、minutes、seconds 的值確定。
 Duration newDuration(boolean isPositive, int years, int months, int days, int hours, int minutes, int seconds)
          獲取 Duration 的新實例,該 Duration 根據 isPositive、years、months、days、hours、minutes、seconds 的值確定。
abstract  Duration newDuration(long durationInMilliSeconds)
          獲取新的 Duration 實例,它將 Duration 指定為毫秒。
abstract  Duration newDuration(String lexicalRepresentation)
          獲取新的 Duration 實例,它根據 XML 網要 1.0 第 3.2.6.1 節中的定義將 Duration 指定為其字元串表示形式 "PnYnMnDTnHnMnS"。
 Duration newDurationDayTime(boolean isPositive, BigInteger day, BigInteger hour, BigInteger minute, BigInteger second)
          根據 XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration 中的定義,使用指定 dayhourminutesecond 創建型別為 xdt:dayTimeDurationDuration
 Duration newDurationDayTime(boolean isPositive, int day, int hour, int minute, int second)
          根據 XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration 中的定義,使用指定 dayhourminutesecond 創建型別為 xdt:dayTimeDurationDuration
 Duration newDurationDayTime(long durationInMilliseconds)
          使用 XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration 中定義的指定毫秒創建型別為 xdt:dayTimeDurationDuration
 Duration newDurationDayTime(String lexicalRepresentation)
          通過解析其 String 表示形式 "PnDTnHnMnS"(XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration)創建型別為 xdt:dayTimeDurationDuration
 Duration newDurationYearMonth(boolean isPositive, BigInteger year, BigInteger month)
          根據 XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration 中的定義,使用指定 yearmonth 創建型別為 xdt:yearMonthDurationDuration
 Duration newDurationYearMonth(boolean isPositive, int year, int month)
          根據 XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration 中的定義,使用指定 yearmonth 創建型別為 xdt:yearMonthDurationDuration
 Duration newDurationYearMonth(long durationInMilliseconds)
          根據 XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration 中的定義,使用指定毫秒創建型別為 xdt:yearMonthDurationDuration
 Duration newDurationYearMonth(String lexicalRepresentation)
          通過解析其 String 表示形式 "PnYnM"(XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration)創建型別為 xdt:yearMonthDurationDuration
static DatatypeFactory newInstance()
          獲取新的 DatatypeFactory 實例。
static DatatypeFactory newInstance(String factoryClassName, ClassLoader classLoader)
          從類別名稱中獲取新的 DatatypeFactory 實例。
abstract  XMLGregorianCalendar newXMLGregorianCalendar()
          創建新的 XMLGregorianCalendar 實例。
abstract  XMLGregorianCalendar newXMLGregorianCalendar(BigInteger year, int month, int day, int hour, int minute, int second, BigDecimal fractionalSecond, int timezone)
          W3C XML 網要 1.0 推薦考慮完整值空間的建構子,該方法用於 xsd:dateTime 和相關的內置資料型別。
abstract  XMLGregorianCalendar newXMLGregorianCalendar(GregorianCalendar cal)
          根據 GregorianCalendar 創建 XMLGregorianCalendar
 XMLGregorianCalendar newXMLGregorianCalendar(int year, int month, int day, int hour, int minute, int second, int millisecond, int timezone)
          java.util.GregorianCalendar 實例需要轉換為 XMLGregorianCalendar 實例的值空間的建構子。
abstract  XMLGregorianCalendar newXMLGregorianCalendar(String lexicalRepresentation)
          通過將字元串解析為詞彙表示形式,創建新的 XMLGregorianCalendar。
 XMLGregorianCalendar newXMLGregorianCalendarDate(int year, int month, int day, int timezone)
          創建 XML 網要內置資料型別 dateg* 的 Java 表示形式。
 XMLGregorianCalendar newXMLGregorianCalendarTime(int hours, int minutes, int seconds, BigDecimal fractionalSecond, int timezone)
          創建 XML 網要內置資料型別 time 的 Java 實例。
 XMLGregorianCalendar newXMLGregorianCalendarTime(int hours, int minutes, int seconds, int timezone)
          創建 XML 網要內置資料型別 time 的 Java 實例。
 XMLGregorianCalendar newXMLGregorianCalendarTime(int hours, int minutes, int seconds, int milliseconds, int timezone)
          創建 XML 網要內置資料型別 time 的 Java 實例。
 
從類別 java.lang.Object 繼承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

欄位詳細資訊

DATATYPEFACTORY_PROPERTY

public static final String DATATYPEFACTORY_PROPERTY

JSR 206:Java(TM) API for XML Processing (JAXP) 1.3 中定義的預設實作類別名稱。

預設值為 javax.xml.datatype.DatatypeFactory

另請參見:
常數欄位值

DATATYPEFACTORY_IMPLEMENTATION_CLASS

public static final String DATATYPEFACTORY_IMPLEMENTATION_CLASS

JSR 206: Java(TM) API for XML Processing (JAXP) 1.3 中定義的預設實作類別名稱。

如果其他實作解析機制都沒有成功,則實作者應該指定將被實例化的恰當類別的名稱。

使用者不應該參考此欄位;該欄位只用來記錄處理器實作詳細資訊。

建構子詳細資訊

DatatypeFactory

protected DatatypeFactory()

受保護的建構子,包外無法實例化。

使用 newInstance() 創建 DatatypeFactory

方法詳細資訊

newInstance

public static DatatypeFactory newInstance()
                                   throws DatatypeConfigurationException

獲取新的 DatatypeFactory 實例。

實作解析機制定義在此 Class 的文檔中。

返回:
新的 DatatypeFactory 實例
拋出:
DatatypeConfigurationException - 如果該實作不可用,或者無法實例化。
另請參見:
newInstance(String factoryClassName, ClassLoader classLoader)

newInstance

public static DatatypeFactory newInstance(String factoryClassName,
                                          ClassLoader classLoader)
                                   throws DatatypeConfigurationException

從類別名稱中獲取新的 DatatypeFactory 實例。此函數在類別路徑中有多個提供者時很有用。它可以對應用程序提供更多的控制,因為它可以指定應該載入哪個提供者。

在應用程序獲取對 DatatypeFactory 的參考後,它可以使用處理器來配置和獲取資料型別實例。

疑難解答提示

設置 jaxp.debug 系統屬性將導致此方法將許多除錯訊息列印到 System.err,這些訊息說明了正在執行的操作以及何處可以找到它。

如有問題,可以嘗試使用以下程式碼:

 java -Djaxp.debug=1 YourProgram ....
 

參數:
factoryClassName - 提供 javax.xml.datatype.DatatypeFactory 實作的完全限定處理器類別名稱。
classLoader - 用來載入處理器類別的 ClassLoader。如果該參數為 null,則使用當前 Thread 的上下文類別載入器來載入處理器類別。
返回:
新的 DatatypeFactory 實例
拋出:
DatatypeConfigurationException - 如果 factoryClassNamenull,或者無法載入和實例化處理器類別。
從以下版本開始:
1.6
另請參見:
newInstance()

newDuration

public abstract Duration newDuration(String lexicalRepresentation)

獲取新的 Duration 實例,它根據 XML 網要 1.0 第 3.2.6.1 節中的定義將 Duration 指定為其字元串表示形式 "PnYnMnDTnHnMnS"。

XML 網要第二部分 Datatypes 中的 3.2.6 節 duration 將持續時間定義如下:

持續時間表示某一時間段。持續時間的值空間是六維空間,其中坐標分別指定 [ISO 8601] 的第 5.5.3.2 節中定義的 Gregorian year、month、day、hour、minute 和 second 元件。這些元件根據其重要性按其出現順序(即 year、month、day、hour、minute、second)排序。

六個值都可以通過創建的 Duration 設置和獲得

XML 網要規範說明值可以為任意大小。實作可以選擇不(或不能)支持任意大和/或小的值。如果超過實作容量,則拋出 UnsupportedOperationException 和指示實作限制的訊息。

參數:
lexicalRepresentation - DurationString 表示形式。
返回:
通過解析 lexicalRepresentation 創建的新 Duration
拋出:
IllegalArgumentException - 如果 lexicalRepresentation 不是 Duration 的有效表示形式。
UnsupportedOperationException - 如果實作無法支持請求值。
NullPointerException - 如果 lexicalRepresentationnull

newDuration

public abstract Duration newDuration(long durationInMilliSeconds)

獲取新的 Duration 實例,它將 Duration 指定為毫秒。

XML 網要第二部分 Datatypes 中的 3.2.6 節將持續時間定義為:

持續時間表示某一時間段。持續時間的值空間是六維空間,其中坐標分別指定 [ISO 8601] 的第 5.5.3.2 節中定義的 Gregorian year、month、day、hour、minute 和 second 元件。這些元件根據其重要性按其出現順序(即 year、month、day、hour、minute 和 second)排序。

六個值都可以通過計算指定毫秒的值來設置,通過創建的 Durationget 方法獲得。該值符合以下規範並由其定義:

通過 GregorianCalendar 使用的歷元開始時間定義預設開始實例:即 Calendar.YEAR = 1970、Calendar.MONTH = Calendar.JANUARYCalendar.DATE = 1 等。這非常重要,因為陽曆中存在變化,例如,對於 month = Calendar.FEBRUARY,閏年會有不同的天數,所以 Duration.getMonths()Duration.getDays() 的結果都會受到影響。

參數:
durationInMilliSeconds - 要創建的 Duration,以毫秒為單位。
返回:
表示 durationInMilliSeconds 的新 Duration

newDuration

public abstract Duration newDuration(boolean isPositive,
                                     BigInteger years,
                                     BigInteger months,
                                     BigInteger days,
                                     BigInteger hours,
                                     BigInteger minutes,
                                     BigDecimal seconds)

獲取 Duration 的新實例,該 Duration 根據 isPositive、years、months、days、hours、minutes、seconds 的值確定。

XML 網要規範說明值可以為任意大小。實作可以選擇不(或不能)支持任意大和/或小的值。如果超過實作容量,則拋出 UnsupportedOperationException 和指示實作限制的訊息。

null 值指示不設置欄位。

參數:
isPositive - 設置為 false 將創建負的 Duration。當 Duration 的長度為零時,將忽略此參數。
years - 此 Duration 的年
months - 此 Duration 的月
days - 此 Duration 的日
hours - 此 Duration 的時
minutes - 此 Duration 的分
seconds - 此 Duration 的秒
返回:
從指定的值創建的新 Duration
拋出:
IllegalArgumentException - 如果值不是 Duration 的有效表示形式:如果所有這些欄位(years、months 等等)為 null,或者任何一個為負。
UnsupportedOperationException - 如果實作無法支持請求值。

newDuration

public Duration newDuration(boolean isPositive,
                            int years,
                            int months,
                            int days,
                            int hours,
                            int minutes,
                            int seconds)

獲取 Duration 的新實例,該 Duration 根據 isPositive、years、months、days、hours、minutes、seconds 的值確定。

DatatypeConstants.FIELD_UNDEFINED 值指示不設置欄位。

參數:
isPositive - 設置為 false 將創建負的 Duration。當 Duration 的長度為零時,將忽略此參數。
years - 此 Duration 的年
months - 此 Duration 的月
days - 此 Duration 的日
hours - 此 Duration 的時
minutes - 此 Duration 的分
seconds - 此 Duration 的秒
返回:
根據指定值創建的新 Duration
拋出:
IllegalArgumentException - 如果值不是 Duration 的有效表示形式:如果任一欄位為負。
另請參見:
newDuration( boolean isPositive, BigInteger years, BigInteger months, BigInteger days, BigInteger hours, BigInteger minutes, BigDecimal seconds)

newDurationDayTime

public Duration newDurationDayTime(String lexicalRepresentation)

通過解析其 String 表示形式 "PnDTnHnMnS"(XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration)創建型別為 xdt:dayTimeDurationDuration

資料型別 xdt:dayTimeDurationxs:duration 的子型別,xs:duration 的詞彙表示形式只包含 day、hour、minute 和 second 元件。此資料型別位於名稱空間 http://www.w3.org/2003/11/xpath-datatypes 中。

四個值都可以從創建的 Duration 設置和獲得。

XML 網要規範說明值可以為任意大小。實作可以選擇不(或不能)支持任意大和/或小的值。如果超過實作容量,則拋出 UnsupportedOperationException 和指示實作限制的訊息。

參數:
lexicalRepresentation - Duration 的詞彙表示形式。
返回:
使用指定 lexicalRepresentation 創建的新 Duration
拋出:
IllegalArgumentException - 如果 lexicalRepresentation 不是只以日期和時間形式表達的 Duration 的有效表示形式。
UnsupportedOperationException - 如果實作無法支持請求值。
NullPointerException - 如果 lexicalRepresentationnull

newDurationDayTime

public Duration newDurationDayTime(long durationInMilliseconds)

使用 XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration 中定義的指定毫秒創建型別為 xdt:dayTimeDurationDuration

資料型別 xdt:dayTimeDurationxs:duration 的子型別,xs:duration 詞彙表示形式只包含 day、hour、minute 和 second 元件。此資料型別位於名稱空間 http://www.w3.org/2003/11/xpath-datatypes 中。

四個值都可以通過計算指定毫秒的值設置,通過創建的 Durationget 方法獲得。該值符合以下規範並由其定義:

通過 GregorianCalendar 使用的歷元開始時間定義預設開始實例:即 Calendar.YEAR = 1970、Calendar.MONTH = Calendar.JANUARYCalendar.DATE = 1 等。這非常重要,因為陽曆中存在變化,例如,對於 month = Calendar.FEBRUARY,閏年會有不同的天數,所以 Duration.getDays() 的結果將受到影響。

丟棄確定 day、hour、minute 和 second 之後所有剩餘毫秒。

參數:
durationInMilliseconds - 要創建的 Duration 的毫秒。
返回:
使用指定 durationInMilliseconds 創建的新 Duration
另請參見:
XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration

newDurationDayTime

public Duration newDurationDayTime(boolean isPositive,
                                   BigInteger day,
                                   BigInteger hour,
                                   BigInteger minute,
                                   BigInteger second)

根據 XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration 中的定義,使用指定 dayhourminutesecond 創建型別為 xdt:dayTimeDurationDuration

資料型別 xdt:dayTimeDurationxs:duration 的子型別,xs:duration 詞彙表示形式只包含 day、hour、minute 和 second 元件。此資料型別位於名稱空間 http://www.w3.org/2003/11/xpath-datatypes 中。

XML 網要規範說明值可以為任意大小。實作可以選擇不(或不能)支持任意大和/或小的值。如果超過實作容量,則拋出 UnsupportedOperationException 和指示實作限制的訊息。

null 值指示不設置欄位。

參數:
isPositive - 設置為 false 將創建負的 Duration。當 Duration 的長度為零時,將忽略此參數。
day - Duration 的日。
hour - Duration 的時。
minute - Duration 的分。
second - Duration 的秒。
返回:
使用指定的 dayhourminutesecond 創建新的 Duration
拋出:
IllegalArgumentException - 如果值不是 Duration 的有效表示形式:如果所有這些欄位(years、months 等等)為 null,或者任何一個為負。
UnsupportedOperationException - 如果實作無法支持請求值。

newDurationDayTime

public Duration newDurationDayTime(boolean isPositive,
                                   int day,
                                   int hour,
                                   int minute,
                                   int second)

根據 XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration 中的定義,使用指定 dayhourminutesecond 創建型別為 xdt:dayTimeDurationDuration

資料型別 xdt:dayTimeDurationxs:duration 的子型別,xs:duration 詞彙表示形式僅包含 day、hour、minute 和 second 元件。此資料型別位於名稱空間 http://www.w3.org/2003/11/xpath-datatypes 中。

DatatypeConstants.FIELD_UNDEFINED 值指示不設置欄位。

參數:
isPositive - 設置為 false 將創建負的 Duration。當 Duration 的長度為零時,將忽略此參數。
day - Duration 的日。
hour - Duration 的時。
minute - Duration 的分。
second - Duration 的秒。
返回:
使用指定的 dayhourminutesecond 創建新的 Duration
拋出:
IllegalArgumentException - 如果值不是 Duration 的有效表示形式:如果所有這些欄位(years、months 等等)為 null,或者任何一個為負。

newDurationYearMonth

public Duration newDurationYearMonth(String lexicalRepresentation)

通過解析其 String 表示形式 "PnYnM"(XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration)創建型別為 xdt:yearMonthDurationDuration

資料型別 xdt:yearMonthDurationxs:duration 的子型別,xs:duration 詞彙表示形式僅包含 year 和 month 元件。此資料型別位於名稱空間 XMLConstants.W3C_XPATH_DATATYPE_NS_URI 中。

這兩個值都可以從創建的 Duration 設置和獲得

XML 網要規範說明值可以為任意大小。實作可以選擇不(或不能)支持任意大和/或小的值。如果超過實作容量,則拋出 UnsupportedOperationException 和指示實作限制的訊息。

參數:
lexicalRepresentation - Duration 的詞彙表示形式。
返回:
使用指定 lexicalRepresentation 創建的新 Duration
拋出:
IllegalArgumentException - 如果 lexicalRepresentation 不是通過 years 和 months 表示的 Duration 的有效表示形式。
UnsupportedOperationException - 如果實作無法支持請求值。
NullPointerException - 如果 lexicalRepresentationnull

newDurationYearMonth

public Duration newDurationYearMonth(long durationInMilliseconds)

根據 XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration 中的定義,使用指定毫秒創建型別為 xdt:yearMonthDurationDuration

資料型別 xdt:yearMonthDurationxs:duration 的子型別,xs:duration 詞彙表示形式只包含 year 和 month 元件。此資料型別位於名稱空間 XMLConstants.W3C_XPATH_DATATYPE_NS_URI 中。

兩個值都可以通過計算指定毫秒的值設置,通過創建的 Durationget 方法獲得。該值符合以下規範並由其定義:

通過 GregorianCalendar 使用的歷元開始時間定義預設開始實例:即 Calendar.YEAR = 1970、Calendar.MONTH = Calendar.JANUARYCalendar.DATE = 1 等。這非常重要,因為陽曆中存在變化,例如,對於 month = Calendar.FEBRUARY,閏年會有不同的天數,所以 Duration.getMonths() 的結果將受到影響。

丟棄確定 year 和 month 之後所有剩餘毫秒。

參數:
durationInMilliseconds - 要創建的 Duration 的毫秒。
返回:
使用指定 durationInMilliseconds 創建的新 Duration

newDurationYearMonth

public Duration newDurationYearMonth(boolean isPositive,
                                     BigInteger year,
                                     BigInteger month)

根據 XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration 中的定義,使用指定 yearmonth 創建型別為 xdt:yearMonthDurationDuration

XML 網要規範說明值可以為任意大小。實作可以選擇不(或不能)支持任意大和/或小的值。如果超過實作容量,則拋出 UnsupportedOperationException 和指示實作限制的訊息。

null 值指示不設置欄位。

參數:
isPositive - 設置為 false 將創建負的 Duration。當 Duration 的長度為零時,將忽略此參數。
year - Duration 的年。
month - Duration 的月。
返回:
使用指定的 yearmonth 創建的新 Duration
拋出:
IllegalArgumentException - 如果值不是 Duration 的有效表示形式:如果所有這些欄位(years、months 等等)為 null,或者任何一個為負。
UnsupportedOperationException - 如果實作無法支持請求值。

newDurationYearMonth

public Duration newDurationYearMonth(boolean isPositive,
                                     int year,
                                     int month)

根據 XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration 中的定義,使用指定 yearmonth 創建型別為 xdt:yearMonthDurationDuration

DatatypeConstants.FIELD_UNDEFINED 值指示不設置欄位。

參數:
isPositive - 設置為 false 將創建負的 Duration。當 Duration 的長度為零時,將忽略此參數。
year - Duration 的年。
month - Duration 的月。
返回:
使用指定的 yearmonth 創建的新 Duration
拋出:
IllegalArgumentException - 如果值不是 Duration 的有效表示形式:如果這些欄位(year 和 month)中的任何一個為負。

newXMLGregorianCalendar

public abstract XMLGregorianCalendar newXMLGregorianCalendar()

創建新的 XMLGregorianCalendar 實例。

設置為 DatatypeConstants.FIELD_UNDEFINED 或 null 的所有日期/時間資料型別欄位。

返回:
新的 XMLGregorianCalendar,其所有日期/時間資料型別欄位設置為 DatatypeConstants.FIELD_UNDEFINED 或 null。

newXMLGregorianCalendar

public abstract XMLGregorianCalendar newXMLGregorianCalendar(String lexicalRepresentation)

通過將字元串解析為詞彙表示形式,創建新的 XMLGregorianCalendar。

XML Schema 1.0 Part 2, Section 3.2.[7-14].1, Lexical Representation 中定義瞭解析詞彙字元串表示形式。

字元串表示形式不能存在任何前導和尾部空格。

逐欄位執行解析,以便以下內容保存任何詞彙正確的字元串 x:

 newXMLGregorianCalendar(x).toXMLFormat().equals(x)
 

XML Schema 1.0 errata, Section 3.2.7.2 中列出的註釋詞彙/規範化表示形式不比對的情況除外。

參數:
lexicalRepresentation - 八個 XML 網要日期/時間資料數型之一的詞彙表示形式。
返回:
根據 lexicalRepresentation 創建的 XMLGregorianCalendar
拋出:
IllegalArgumentException - 如果 lexicalRepresentation 不是有效的 XMLGregorianCalendar
NullPointerException - 如果 lexicalRepresentationnull

newXMLGregorianCalendar

public abstract XMLGregorianCalendar newXMLGregorianCalendar(GregorianCalendar cal)

根據 GregorianCalendar 創建 XMLGregorianCalendar

GregorianCalendarXMLGregorianCalendar 的逐欄位轉換
java.util.GregorianCalendar 欄位 javax.xml.datatype.XMLGregorianCalendar 欄位
ERA == GregorianCalendar.BC ? -YEAR :YEAR XMLGregorianCalendar.setYear(int year)
MONTH + 1 XMLGregorianCalendar.setMonth(int month)
DAY_OF_MONTH XMLGregorianCalendar.setDay(int day)
HOUR_OF_DAY, MINUTE, SECOND, MILLISECOND XMLGregorianCalendar.setTime(int hour, int minute, int second, BigDecimal fractional)
(ZONE_OFFSET + DST_OFFSET) / (60*1000)
(以分為單位)
XMLGregorianCalendar.setTimezone(int offset)*

* 轉換丟失資訊。不能以 XML 網要 1.0 日期/時間資料型別表示形式表示 java.util.GregorianCalendar 夏令時時區 id。

要計算返回值的 TimeZone 欄位,


newXMLGregorianCalendar

public abstract XMLGregorianCalendar newXMLGregorianCalendar(BigInteger year,
                                                             int month,
                                                             int day,
                                                             int hour,
                                                             int minute,
                                                             int second,
                                                             BigDecimal fractionalSecond,
                                                             int timezone)

W3C XML 網要 1.0 推薦考慮完整值空間的建構子,該方法用於 xsd:dateTime 和相關的內置資料型別。注意,year 參數支持任意大的數字,fractionalSecond 具有無限精度。

null 值指示不設置欄位。

參數:
year - 要創建的 XMLGregorianCalendar 的年。
month - 要創建的 XMLGregorianCalendar 的月。
day - 要創建的 XMLGregorianCalendar 的日。
hour - 要創建的 XMLGregorianCalendar 的時。
minute - 要創建的 XMLGregorianCalendar 的分。
second - 要創建的 XMLGregorianCalendar 的秒。
fractionalSecond - 要創建的 XMLGregorianCalendar 的 fractionalSecond。
timezone - 要創建的 XMLGregorianCalendar 的時區。
返回:
根據指定值創建的 XMLGregorianCalendar
拋出:
IllegalArgumentException - 如果任一參數的值超出由 XMLGregorianCalendar 中詞彙 Data Mapping 表確定的欄位的最大值約束,或者復合值組成了 XMLGregorianCalendar.isValid() 確定為無效的 XMLGregorianCalendar 實例。

newXMLGregorianCalendar

public XMLGregorianCalendar newXMLGregorianCalendar(int year,
                                                    int month,
                                                    int day,
                                                    int hour,
                                                    int minute,
                                                    int second,
                                                    int millisecond,
                                                    int timezone)

java.util.GregorianCalendar 實例需要轉換為 XMLGregorianCalendar 實例的值空間的建構子。

XMLGregorianCalendar eonfractionalSecond 設置為 null

DatatypeConstants.FIELD_UNDEFINED 值指示不設置欄位。

參數:
year - 要創建的 XMLGregorianCalendar 的年。
month - 要創建的 XMLGregorianCalendar 的月。
day - 要創建的 XMLGregorianCalendar 的日。
hour - 要創建的 XMLGregorianCalendar 的時。
minute - 要創建的 XMLGregorianCalendar 的分。
second - 要創建的 XMLGregorianCalendar 的秒。
millisecond - 要創建的 XMLGregorianCalendar 的毫秒。
timezone - 要創建的 XMLGregorianCalendar 的時區。
返回:
根據指定值創建的 XMLGregorianCalendar
拋出:
IllegalArgumentException - 如果任一參數的值超出由 XMLGregorianCalendar 中詞彙 Data Mapping 表確定的欄位的最大值約束,或者復合值組成了 XMLGregorianCalendar.isValid() 確定為無效的 XMLGregorianCalendar 實例。

newXMLGregorianCalendarDate

public XMLGregorianCalendar newXMLGregorianCalendarDate(int year,
                                                        int month,
                                                        int day,
                                                        int timezone)

創建 XML 網要內置資料型別 dateg* 的 Java 表示形式。

例如,通過調用此處理器,並將 monthday 參數設置為 DatatypeConstants.FIELD_UNDEFINED,可以創建 gYear 實例。

DatatypeConstants.FIELD_UNDEFINED 值指示不設置欄位。

參數:
year - 要創建的 XMLGregorianCalendar 的年。
month - 要創建的 XMLGregorianCalendar 的月。
day - 要創建的 XMLGregorianCalendar 的日。
timezone - 以分為單位的偏移量。DatatypeConstants.FIELD_UNDEFINED 指示未設置可選欄位。
返回:
根據參數值創建的 XMLGregorianCalendar
拋出:
IllegalArgumentException - 如果任一參數的值超出由 XMLGregorianCalendar 中詞彙 Data Mapping 表確定的欄位的最大值約束,或者復合值組成了 XMLGregorianCalendar.isValid() 確定為無效的 XMLGregorianCalendar 實例。
另請參見:
DatatypeConstants.FIELD_UNDEFINED

newXMLGregorianCalendarTime

public XMLGregorianCalendar newXMLGregorianCalendarTime(int hours,
                                                        int minutes,
                                                        int seconds,
                                                        int timezone)

創建 XML 網要內置資料型別 time 的 Java 實例。

DatatypeConstants.FIELD_UNDEFINED 值指示不設置欄位。

參數:
hours - 小時數
minutes - 分鐘數
seconds - 秒數
timezone - 以分鐘為單位的偏移量。DatatypeConstants.FIELD_UNDEFINED 指示未設置可選欄位。
返回:
根據參數值創建的 XMLGregorianCalendar
拋出:
IllegalArgumentException - 如果任何單個參數的值超出由 XMLGregorianCalendar 中詞彙 Data Mapping 表確定的欄位的最大值約束,或者復合值組成了 XMLGregorianCalendar.isValid() 確定為無效的 XMLGregorianCalendar 實例。
另請參見:
DatatypeConstants.FIELD_UNDEFINED

newXMLGregorianCalendarTime

public XMLGregorianCalendar newXMLGregorianCalendarTime(int hours,
                                                        int minutes,
                                                        int seconds,
                                                        BigDecimal fractionalSecond,
                                                        int timezone)

創建 XML 網要內置資料型別 time 的 Java 實例。

null 值指示不設置欄位。

DatatypeConstants.FIELD_UNDEFINED 值指示不設置欄位。

參數:
hours - 小時數
minutes - 分鐘數
seconds - 秒數
fractionalSecond - null 的值,它指示未設置此可選欄位。
timezone - 以分為單位的偏移量。DatatypeConstants.FIELD_UNDEFINED 指示未設置可選欄位。
返回:
根據參數值創建的 XMLGregorianCalendar
拋出:
IllegalArgumentException - 如果任一參數的值超出由 XMLGregorianCalendar 中詞彙 Data Mapping 表確定的欄位的最大值約束,或者復合值組成了 XMLGregorianCalendar.isValid() 確定為無效的 XMLGregorianCalendar 實例。
另請參見:
DatatypeConstants.FIELD_UNDEFINED

newXMLGregorianCalendarTime

public XMLGregorianCalendar newXMLGregorianCalendarTime(int hours,
                                                        int minutes,
                                                        int seconds,
                                                        int milliseconds,
                                                        int timezone)

創建 XML 網要內置資料型別 time 的 Java 實例。

DatatypeConstants.FIELD_UNDEFINED 值指示不設置欄位。

參數:
hours - 小時數
minutes - 分鐘數
seconds - 秒數
milliseconds - 毫秒數
timezone - 以分鐘為單位的偏移量。DatatypeConstants.FIELD_UNDEFINED 指示未設置可選欄位。
返回:
根據參數值創建的 XMLGregorianCalendar
拋出:
IllegalArgumentException - 如果任一參數的值超出由 XMLGregorianCalendar 中詞彙 Data Mapping 表確定的欄位的最大值約束,或者復合值了 XMLGregorianCalendar.isValid() 確定為無效的 XMLGregorianCalendar 實例。
另請參見:
DatatypeConstants.FIELD_UNDEFINED

JavaTM 2 Platform
Standard Ed. 6

提交錯誤或意見

版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only