Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#constants) \| [Fields](https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#lfields) \| [Protected Ctors](https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#proctors) \| [Methods](https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#inhmethods)

# DatatypeFactory


`
public


abstract
class
DatatypeFactory
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | javax.xml.datatype.DatatypeFactory |

<br />

*** ** * ** ***

<br />

Factory that creates new `javax.xml.datatype` `Object`s that map XML to/from Java `Object`s.

`https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#newInstance()` is used to create a new `DatatypeFactory`.
The following implementation resolution mechanisms are used in the following order:

1. If the system property specified by `https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#DATATYPEFACTORY_PROPERTY`, "`javax.xml.datatype.DatatypeFactory`", exists, a class with the name of the property's value is instantiated. Any Exception thrown during the instantiation process is wrapped as a `https://developer.android.com/reference/javax/xml/datatype/DatatypeConfigurationException`.
2. If the file ${JAVA_HOME}/lib/jaxp.properties exists, it is loaded in a `https://developer.android.com/reference/java/util/Properties` `Object`. The `Properties` `Object ` is then queried for the property as documented in the prior step and processed as documented in the prior step.
3. The services resolution mechanism is used, e.g. `META-INF/services/java.xml.datatype.DatatypeFactory`. Any Exception thrown during the instantiation process is wrapped as a `https://developer.android.com/reference/javax/xml/datatype/DatatypeConfigurationException`.
4. The final mechanism is to attempt to instantiate the `Class` specified by `https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#DATATYPEFACTORY_IMPLEMENTATION_CLASS`, "`javax.xml.datatype.DatatypeFactoryImpl`". Any Exception thrown during the instantiation process is wrapped as a `https://developer.android.com/reference/javax/xml/datatype/DatatypeConfigurationException`.

Note that you must supply your own implementation (such as Xerces); Android does not ship with a default implementation.

## Summary

| ### Constants ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#DATATYPEFACTORY_PROPERTY` <br /> Default property name as defined in JSR 206: Java(TM) API for XML Processing (JAXP) 1.3. |

| ### Fields ||
|---|---|
| ` public static final https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#DATATYPEFACTORY_IMPLEMENTATION_CLASS` <br /> Default implementation class name as defined in JSR 206: Java(TM) API for XML Processing (JAXP) 1.3. |

| ### Protected constructors ||
|---|---|
| ` https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#DatatypeFactory()() ` <br /> Protected constructor to prevent instantiation outside of package. |

| ### Public methods ||
|---|---|
| ` abstract https://developer.android.com/reference/javax/xml/datatype/Duration` | ` https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#newDuration(boolean,%20java.math.BigInteger,%20java.math.BigInteger,%20java.math.BigInteger,%20java.math.BigInteger,%20java.math.BigInteger,%20java.math.BigDecimal)(boolean isPositive, https://developer.android.com/reference/java/math/BigInteger years, https://developer.android.com/reference/java/math/BigInteger months, https://developer.android.com/reference/java/math/BigInteger days, https://developer.android.com/reference/java/math/BigInteger hours, https://developer.android.com/reference/java/math/BigInteger minutes, https://developer.android.com/reference/java/math/BigDecimal seconds) ` <br /> Obtain a new instance of a `Duration` specifying the `Duration` as isPositive, years, months, days, hours, minutes, seconds. |
| ` https://developer.android.com/reference/javax/xml/datatype/Duration` | ` https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#newDuration(boolean,%20int,%20int,%20int,%20int,%20int,%20int)(boolean isPositive, int years, int months, int days, int hours, int minutes, int seconds) ` <br /> Obtain a new instance of a `Duration` specifying the `Duration` as isPositive, years, months, days, hours, minutes, seconds. |
| ` abstract https://developer.android.com/reference/javax/xml/datatype/Duration` | ` https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#newDuration(long)(long durationInMilliSeconds) ` <br /> Obtain a new instance of a `Duration` specifying the `Duration` as milliseconds. |
| ` abstract https://developer.android.com/reference/javax/xml/datatype/Duration` | ` https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#newDuration(java.lang.String)(https://developer.android.com/reference/java/lang/String lexicalRepresentation) ` <br /> Obtain a new instance of a `Duration` specifying the `Duration` as its string representation, "PnYnMnDTnHnMnS", as defined in XML Schema 1.0 section 3.2.6.1. |
| ` https://developer.android.com/reference/javax/xml/datatype/Duration` | ` https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#newDurationDayTime(long)(long durationInMilliseconds) ` <br /> Create a `Duration` of type `xdt:dayTimeDuration` using the specified milliseconds as defined in [XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration](http://www.w3.org/TR/xpath-datamodel#dt-dayTimeDuration). |
| ` https://developer.android.com/reference/javax/xml/datatype/Duration` | ` https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#newDurationDayTime(boolean,%20java.math.BigInteger,%20java.math.BigInteger,%20java.math.BigInteger,%20java.math.BigInteger)(boolean isPositive, https://developer.android.com/reference/java/math/BigInteger day, https://developer.android.com/reference/java/math/BigInteger hour, https://developer.android.com/reference/java/math/BigInteger minute, https://developer.android.com/reference/java/math/BigInteger second) ` <br /> Create a `Duration` of type `xdt:dayTimeDuration` using the specified `day`, `hour`, `minute` and `second` as defined in [XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration](http://www.w3.org/TR/xpath-datamodel#dt-dayTimeDuration). |
| ` https://developer.android.com/reference/javax/xml/datatype/Duration` | ` https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#newDurationDayTime(boolean,%20int,%20int,%20int,%20int)(boolean isPositive, int day, int hour, int minute, int second) ` <br /> Create a `Duration` of type `xdt:dayTimeDuration` using the specified `day`, `hour`, `minute` and `second` as defined in [XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration](http://www.w3.org/TR/xpath-datamodel#dt-dayTimeDuration). |
| ` https://developer.android.com/reference/javax/xml/datatype/Duration` | ` https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#newDurationDayTime(java.lang.String)(https://developer.android.com/reference/java/lang/String lexicalRepresentation) ` <br /> Create a `Duration` of type `xdt:dayTimeDuration` by parsing its `String` representation, "*PnDTnHnMnS* ", [XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration](http://www.w3.org/TR/xpath-datamodel#dt-dayTimeDuration). |
| ` https://developer.android.com/reference/javax/xml/datatype/Duration` | ` https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#newDurationYearMonth(java.lang.String)(https://developer.android.com/reference/java/lang/String lexicalRepresentation) ` <br /> Create a `Duration` of type `xdt:yearMonthDuration` by parsing its `String` representation, "*PnYnM* ", [XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration](http://www.w3.org/TR/xpath-datamodel#dt-yearMonthDuration). |
| ` https://developer.android.com/reference/javax/xml/datatype/Duration` | ` https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#newDurationYearMonth(boolean,%20java.math.BigInteger,%20java.math.BigInteger)(boolean isPositive, https://developer.android.com/reference/java/math/BigInteger year, https://developer.android.com/reference/java/math/BigInteger month) ` <br /> Create a `Duration` of type `xdt:yearMonthDuration` using the specified `year` and `month` as defined in [XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration](http://www.w3.org/TR/xpath-datamodel#dt-yearMonthyDuration). |
| ` https://developer.android.com/reference/javax/xml/datatype/Duration` | ` https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#newDurationYearMonth(boolean,%20int,%20int)(boolean isPositive, int year, int month) ` <br /> Create a `Duration` of type `xdt:yearMonthDuration` using the specified `year` and `month` as defined in [XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration](http://www.w3.org/TR/xpath-datamodel#dt-yearMonthyDuration). |
| ` https://developer.android.com/reference/javax/xml/datatype/Duration` | ` https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#newDurationYearMonth(long)(long durationInMilliseconds) ` <br /> Create a `Duration` of type `xdt:yearMonthDuration` using the specified milliseconds as defined in [XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration](http://www.w3.org/TR/xpath-datamodel#dt-yearMonthDuration). |
| ` static https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory` | ` https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#newInstance(java.lang.String,%20java.lang.ClassLoader)(https://developer.android.com/reference/java/lang/String factoryClassName, https://developer.android.com/reference/java/lang/ClassLoader classLoader) ` Returns an instance of the named implementation of `DatatypeFactory`. |
| ` static https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory` | ` https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#newInstance()() ` <br /> Obtain a new instance of a `DatatypeFactory`. |
| ` abstract https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar` | ` https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#newXMLGregorianCalendar(java.lang.String)(https://developer.android.com/reference/java/lang/String lexicalRepresentation) ` <br /> Create a new XMLGregorianCalendar by parsing the String as a lexical representation. |
| ` abstract https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar` | ` https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#newXMLGregorianCalendar(java.util.GregorianCalendar)(https://developer.android.com/reference/java/util/GregorianCalendar cal) ` <br /> Create an `XMLGregorianCalendar` from a `https://developer.android.com/reference/java/util/GregorianCalendar`. |
| ` https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar` | ` https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#newXMLGregorianCalendar(int,%20int,%20int,%20int,%20int,%20int,%20int,%20int)(int year, int month, int day, int hour, int minute, int second, int millisecond, int timezone) ` <br /> Constructor of value spaces that a `java.util.GregorianCalendar` instance would need to convert to an `XMLGregorianCalendar` instance. |
| ` abstract https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar` | ` https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#newXMLGregorianCalendar(java.math.BigInteger,%20int,%20int,%20int,%20int,%20int,%20java.math.BigDecimal,%20int)(https://developer.android.com/reference/java/math/BigInteger year, int month, int day, int hour, int minute, int second, https://developer.android.com/reference/java/math/BigDecimal fractionalSecond, int timezone) ` <br /> Constructor allowing for complete value spaces allowed by W3C XML Schema 1.0 recommendation for xsd:dateTime and related builtin datatypes. |
| ` abstract https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar` | ` https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#newXMLGregorianCalendar()() ` <br /> Create a new instance of an `XMLGregorianCalendar`. |
| ` https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar` | ` https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#newXMLGregorianCalendarDate(int,%20int,%20int,%20int)(int year, int month, int day, int timezone) ` <br /> Create a Java representation of XML Schema builtin datatype `date` or `g*`. |
| ` https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar` | ` https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#newXMLGregorianCalendarTime(int,%20int,%20int,%20java.math.BigDecimal,%20int)(int hours, int minutes, int seconds, https://developer.android.com/reference/java/math/BigDecimal fractionalSecond, int timezone) ` <br /> Create a Java instance of XML Schema builtin datatype time. |
| ` https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar` | ` https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#newXMLGregorianCalendarTime(int,%20int,%20int,%20int,%20int)(int hours, int minutes, int seconds, int milliseconds, int timezone) ` <br /> Create a Java instance of XML Schema builtin datatype time. |
| ` https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar` | ` https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#newXMLGregorianCalendarTime(int,%20int,%20int,%20int)(int hours, int minutes, int seconds, int timezone) ` <br /> Create a Java instance of XML Schema builtin datatype `time`. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Constants

### DATATYPEFACTORY_PROPERTY

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String DATATYPEFACTORY_PROPERTY
```

<br />

Default property name as defined in JSR 206: Java(TM) API for XML Processing (JAXP) 1.3.

Default value is `javax.xml.datatype.DatatypeFactory`.

<br />

<br />

Constant Value:

"javax.xml.datatype.DatatypeFactory"


## Fields

### DATATYPEFACTORY_IMPLEMENTATION_CLASS

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String DATATYPEFACTORY_IMPLEMENTATION_CLASS
```

<br />

Default implementation class name as defined in JSR 206: Java(TM) API for XML Processing (JAXP) 1.3.

Default value is `org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl`.

<br />

<br />

## Protected constructors

### DatatypeFactory

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected DatatypeFactory ()
```

<br />

Protected constructor to prevent instantiation outside of package.

Use `https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#newInstance()` to create a `DatatypeFactory`.

<br />

<br />

## Public methods

### newDuration

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

<br />

Obtain a new instance of a `Duration`
specifying the `Duration` as isPositive, years, months, days, hours, minutes, seconds.

The XML Schema specification states that values can be of an arbitrary size.
Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
An `https://developer.android.com/reference/java/lang/UnsupportedOperationException` will be thrown with a message indicating implementation limits
if implementation capacities are exceeded.

A `null` value indicates that field is not set.

<br />

<br />

| Parameters ||
|---|---|
| `isPositive` | `boolean`: Set to `false` to create a negative duration. When the length of the duration is zero, this parameter will be ignored. <br /> |
| `years` | `BigInteger`: of this `Duration` <br /> |
| `months` | `BigInteger`: of this `Duration` <br /> |
| `days` | `BigInteger`: of this `Duration` <br /> |
| `hours` | `BigInteger`: of this `Duration` <br /> |
| `minutes` | `BigInteger`: of this `Duration` <br /> |
| `seconds` | `BigDecimal`: of this `Duration` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/datatype/Duration` | New `Duration` created from the specified values. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If values are not a valid representation of a `Duration`. |
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException` | If implementation cannot support requested values. |

### newDuration

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

<br />

Obtain a new instance of a `Duration`
specifying the `Duration` as isPositive, years, months, days, hours, minutes, seconds.

A `https://developer.android.com/reference/javax/xml/datatype/DatatypeConstants#FIELD_UNDEFINED` value indicates that field is not set.

<br />

<br />

| Parameters ||
|---|---|
| `isPositive` | `boolean`: Set to `false` to create a negative duration. When the length of the duration is zero, this parameter will be ignored. <br /> |
| `years` | `int`: of this `Duration` <br /> |
| `months` | `int`: of this `Duration` <br /> |
| `days` | `int`: of this `Duration` <br /> |
| `hours` | `int`: of this `Duration` <br /> |
| `minutes` | `int`: of this `Duration` <br /> |
| `seconds` | `int`: of this `Duration` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/datatype/Duration` | New `Duration` created from the specified values. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If values are not a valid representation of a `Duration`. |

**See also:**

- `https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#newDuration(boolean,%20java.math.BigInteger,%20java.math.BigInteger,%20java.math.BigInteger,%20java.math.BigInteger,%20java.math.BigInteger,%20java.math.BigDecimal)`

### newDuration

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract Duration newDuration (long durationInMilliSeconds)
```

<br />

Obtain a new instance of a `Duration`
specifying the `Duration` as milliseconds.

XML Schema Part 2: Datatypes, 3.2.6 duration, defines `duration` as:
> duration represents a duration of time. The value space of duration is a six-dimensional space where the coordinates designate the Gregorian year, month, day, hour, minute, and second components defined in Section 5.5.3.2 of \[ISO 8601\], respectively. These components are ordered in their significance by their order of appearance i.e. as year, month, day, hour, minute, and second.

All six values are set by computing their values from the specified milliseconds
and are available using the `get` methods of the created `https://developer.android.com/reference/javax/xml/datatype/Duration`.
The values conform to and are defined by:

- ISO 8601:2000(E) Section 5.5.3.2 Alternative format
- [W3C XML Schema 1.0 Part 2, Appendix D, ISO 8601 Date and Time Formats](http://www.w3.org/TR/xmlschema-2/#isoformats)
- `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar` Date/Time Datatype Field Mapping Between XML Schema 1.0 and Java Representation

The default start instance is defined by `https://developer.android.com/reference/java/util/GregorianCalendar`'s use of the start of the epoch: i.e.,
`https://developer.android.com/reference/java/util/Calendar#YEAR` = 1970,
`https://developer.android.com/reference/java/util/Calendar#MONTH` = `https://developer.android.com/reference/java/util/Calendar#JANUARY`,
`https://developer.android.com/reference/java/util/Calendar#DATE` = 1, etc.
This is important as there are variations in the Gregorian Calendar,
e.g. leap years have different days in the month = `https://developer.android.com/reference/java/util/Calendar#FEBRUARY`
so the result of `https://developer.android.com/reference/javax/xml/datatype/Duration#getMonths()` and `https://developer.android.com/reference/javax/xml/datatype/Duration#getDays()` can be influenced.

<br />

<br />

| Parameters ||
|---|---|
| `durationInMilliSeconds` | `long`: Duration in milliseconds to create. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/datatype/Duration` | New `Duration` representing `durationInMilliSeconds`. <br /> |

### newDuration

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract Duration newDuration (String lexicalRepresentation)
```

<br />

Obtain a new instance of a `Duration`
specifying the `Duration` as its string representation, "PnYnMnDTnHnMnS",
as defined in XML Schema 1.0 section 3.2.6.1.

XML Schema Part 2: Datatypes, 3.2.6 duration, defines `duration` as:
> duration represents a duration of time. The value space of duration is a six-dimensional space where the coordinates designate the Gregorian year, month, day, hour, minute, and second components defined in Section 5.5.3.2 of \[ISO 8601\], respectively. These components are ordered in their significance by their order of appearance i.e. as year, month, day, hour, minute, and second.

All six values are set and available from the created `https://developer.android.com/reference/javax/xml/datatype/Duration`

The XML Schema specification states that values can be of an arbitrary size.
Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
An `https://developer.android.com/reference/java/lang/UnsupportedOperationException` will be thrown with a message indicating implementation limits
if implementation capacities are exceeded.

<br />

<br />

| Parameters ||
|---|---|
| `lexicalRepresentation` | `String`: `String` representation of a `Duration`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/datatype/Duration` | New `Duration` created from parsing the `lexicalRepresentation`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If `lexicalRepresentation` is not a valid representation of a `Duration`. |
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `lexicalRepresentation` is `null`. |
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException` | If implementation cannot support requested values. |

### newDurationDayTime

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Duration newDurationDayTime (long durationInMilliseconds)
```

<br />

Create a `Duration` of type `xdt:dayTimeDuration` using the specified milliseconds as defined in
[XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration](http://www.w3.org/TR/xpath-datamodel#dt-dayTimeDuration).

The datatype `xdt:dayTimeDuration` is a subtype of `xs:duration`
whose lexical representation contains only day, hour, minute, and second components.
This datatype resides in the namespace `http://www.w3.org/2003/11/xpath-datatypes`.

All four values are set by computing their values from the specified milliseconds
and are available using the `get` methods of the created `https://developer.android.com/reference/javax/xml/datatype/Duration`.
The values conform to and are defined by:

- ISO 8601:2000(E) Section 5.5.3.2 Alternative format
- [W3C XML Schema 1.0 Part 2, Appendix D, ISO 8601 Date and Time Formats](http://www.w3.org/TR/xmlschema-2/#isoformats)
- `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar` Date/Time Datatype Field Mapping Between XML Schema 1.0 and Java Representation

The default start instance is defined by `https://developer.android.com/reference/java/util/GregorianCalendar`'s use of the start of the epoch: i.e.,
`https://developer.android.com/reference/java/util/Calendar#YEAR` = 1970,
`https://developer.android.com/reference/java/util/Calendar#MONTH` = `https://developer.android.com/reference/java/util/Calendar#JANUARY`,
`https://developer.android.com/reference/java/util/Calendar#DATE` = 1, etc.
This is important as there are variations in the Gregorian Calendar,
e.g. leap years have different days in the month = `https://developer.android.com/reference/java/util/Calendar#FEBRUARY`
so the result of `https://developer.android.com/reference/javax/xml/datatype/Duration#getDays()` can be influenced.

Any remaining milliseconds after determining the day, hour, minute and second are discarded.

<br />

<br />

| Parameters ||
|---|---|
| `durationInMilliseconds` | `long`: Milliseconds of `Duration` to create. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/datatype/Duration` | New `Duration` created with the specified `durationInMilliseconds`. <br /> |

**See also:**

- [XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration](http://www.w3.org/TR/xpath-datamodel#dt-dayTimeDuration)

### newDurationDayTime

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

<br />

Create a `Duration` of type `xdt:dayTimeDuration` using the specified
`day`, `hour`, `minute` and `second` as defined in
[XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration](http://www.w3.org/TR/xpath-datamodel#dt-dayTimeDuration).

The datatype `xdt:dayTimeDuration` is a subtype of `xs:duration`
whose lexical representation contains only day, hour, minute, and second components.
This datatype resides in the namespace `http://www.w3.org/2003/11/xpath-datatypes`.

The XML Schema specification states that values can be of an arbitrary size.
Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
An `https://developer.android.com/reference/java/lang/UnsupportedOperationException` will be thrown with a message indicating implementation limits
if implementation capacities are exceeded.

A `null` value indicates that field is not set.

<br />

<br />

| Parameters ||
|---|---|
| `isPositive` | `boolean`: Set to `false` to create a negative duration. When the length of the duration is zero, this parameter will be ignored. <br /> |
| `day` | `BigInteger`: Day of `Duration`. <br /> |
| `hour` | `BigInteger`: Hour of `Duration`. <br /> |
| `minute` | `BigInteger`: Minute of `Duration`. <br /> |
| `second` | `BigInteger`: Second of `Duration`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/datatype/Duration` | New `Duration` created with the specified `day`, `hour`, `minute` and `second`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If any values would create an invalid `Duration`. |
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException` | If implementation cannot support requested values. |

### newDurationDayTime

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

<br />

Create a `Duration` of type `xdt:dayTimeDuration` using the specified
`day`, `hour`, `minute` and `second` as defined in
[XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration](http://www.w3.org/TR/xpath-datamodel#dt-dayTimeDuration).

The datatype `xdt:dayTimeDuration` is a subtype of `xs:duration`
whose lexical representation contains only day, hour, minute, and second components.
This datatype resides in the namespace `http://www.w3.org/2003/11/xpath-datatypes`.

A `https://developer.android.com/reference/javax/xml/datatype/DatatypeConstants#FIELD_UNDEFINED` value indicates that field is not set.

<br />

<br />

| Parameters ||
|---|---|
| `isPositive` | `boolean`: Set to `false` to create a negative duration. When the length of the duration is zero, this parameter will be ignored. <br /> |
| `day` | `int`: Day of `Duration`. <br /> |
| `hour` | `int`: Hour of `Duration`. <br /> |
| `minute` | `int`: Minute of `Duration`. <br /> |
| `second` | `int`: Second of `Duration`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/datatype/Duration` | New `Duration` created with the specified `day`, `hour`, `minute` and `second`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If any values would create an invalid `Duration`. |

### newDurationDayTime

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Duration newDurationDayTime (String lexicalRepresentation)
```

<br />

Create a `Duration` of type `xdt:dayTimeDuration` by parsing its `String` representation,
"*PnDTnHnMnS* ", [XQuery 1.0 and XPath 2.0 Data Model, xdt:dayTimeDuration](http://www.w3.org/TR/xpath-datamodel#dt-dayTimeDuration).

The datatype `xdt:dayTimeDuration` is a subtype of `xs:duration`
whose lexical representation contains only day, hour, minute, and second components.
This datatype resides in the namespace `http://www.w3.org/2003/11/xpath-datatypes`.

All four values are set and available from the created `https://developer.android.com/reference/javax/xml/datatype/Duration`

The XML Schema specification states that values can be of an arbitrary size.
Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
An `https://developer.android.com/reference/java/lang/UnsupportedOperationException` will be thrown with a message indicating implementation limits
if implementation capacities are exceeded.

<br />

<br />

| Parameters ||
|---|---|
| `lexicalRepresentation` | `String`: Lexical representation of a duration. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/datatype/Duration` | New `Duration` created using the specified `lexicalRepresentation`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If the given string does not conform to the aforementioned specification. |
| `https://developer.android.com/reference/java/lang/NullPointerException` | If `lexicalRepresentation` is `null`. |
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException` | If implementation cannot support requested values. |

### newDurationYearMonth

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Duration newDurationYearMonth (String lexicalRepresentation)
```

<br />

Create a `Duration` of type `xdt:yearMonthDuration` by parsing its `String` representation,
"*PnYnM* ", [XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration](http://www.w3.org/TR/xpath-datamodel#dt-yearMonthDuration).

The datatype `xdt:yearMonthDuration` is a subtype of `xs:duration`
whose lexical representation contains only year and month components.
This datatype resides in the namespace `https://developer.android.com/reference/javax/xml/XMLConstants#W3C_XPATH_DATATYPE_NS_URI`.

Both values are set and available from the created `https://developer.android.com/reference/javax/xml/datatype/Duration`

The XML Schema specification states that values can be of an arbitrary size.
Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
An `https://developer.android.com/reference/java/lang/UnsupportedOperationException` will be thrown with a message indicating implementation limits
if implementation capacities are exceeded.

<br />

<br />

| Parameters ||
|---|---|
| `lexicalRepresentation` | `String`: Lexical representation of a duration. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/datatype/Duration` | New `Duration` created using the specified `lexicalRepresentation`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If the `lexicalRepresentation` does not conform to the specification. |
| `https://developer.android.com/reference/java/lang/NullPointerException` | If `lexicalRepresentation` is `null`. |
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException` | If implementation cannot support requested values. |

### newDurationYearMonth

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

<br />

Create a `Duration` of type `xdt:yearMonthDuration` using the specified
`year` and `month` as defined in
[XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration](http://www.w3.org/TR/xpath-datamodel#dt-yearMonthyDuration).

The XML Schema specification states that values can be of an arbitrary size.
Implementations may chose not to or be incapable of supporting arbitrarily large and/or small values.
An `https://developer.android.com/reference/java/lang/UnsupportedOperationException` will be thrown with a message indicating implementation limits
if implementation capacities are exceeded.

A `null` value indicates that field is not set.

<br />

<br />

| Parameters ||
|---|---|
| `isPositive` | `boolean`: Set to `false` to create a negative duration. When the length of the duration is zero, this parameter will be ignored. <br /> |
| `year` | `BigInteger`: Year of `Duration`. <br /> |
| `month` | `BigInteger`: Month of `Duration`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/datatype/Duration` | New `Duration` created using the specified `year` and `month`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If any values would create an invalid `Duration`. |
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException` | If implementation cannot support requested values. |

### newDurationYearMonth

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

<br />

Create a `Duration` of type `xdt:yearMonthDuration` using the specified
`year` and `month` as defined in
[XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration](http://www.w3.org/TR/xpath-datamodel#dt-yearMonthyDuration).

A `https://developer.android.com/reference/javax/xml/datatype/DatatypeConstants#FIELD_UNDEFINED` value indicates that field is not set.

<br />

<br />

| Parameters ||
|---|---|
| `isPositive` | `boolean`: Set to `false` to create a negative duration. When the length of the duration is zero, this parameter will be ignored. <br /> |
| `year` | `int`: Year of `Duration`. <br /> |
| `month` | `int`: Month of `Duration`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/datatype/Duration` | New `Duration` created using the specified `year` and `month`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If any values would create an invalid `Duration`. |

### newDurationYearMonth

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Duration newDurationYearMonth (long durationInMilliseconds)
```

<br />

Create a `Duration` of type `xdt:yearMonthDuration` using the specified milliseconds as defined in
[XQuery 1.0 and XPath 2.0 Data Model, xdt:yearMonthDuration](http://www.w3.org/TR/xpath-datamodel#dt-yearMonthDuration).

The datatype `xdt:yearMonthDuration` is a subtype of `xs:duration`
whose lexical representation contains only year and month components.
This datatype resides in the namespace `https://developer.android.com/reference/javax/xml/XMLConstants#W3C_XPATH_DATATYPE_NS_URI`.

Both values are set by computing their values from the specified milliseconds
and are available using the `get` methods of the created `https://developer.android.com/reference/javax/xml/datatype/Duration`.
The values conform to and are defined by:

- ISO 8601:2000(E) Section 5.5.3.2 Alternative format
- [W3C XML Schema 1.0 Part 2, Appendix D, ISO 8601 Date and Time Formats](http://www.w3.org/TR/xmlschema-2/#isoformats)
- `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar` Date/Time Datatype Field Mapping Between XML Schema 1.0 and Java Representation

The default start instance is defined by `https://developer.android.com/reference/java/util/GregorianCalendar`'s use of the start of the epoch: i.e.,
`https://developer.android.com/reference/java/util/Calendar#YEAR` = 1970,
`https://developer.android.com/reference/java/util/Calendar#MONTH` = `https://developer.android.com/reference/java/util/Calendar#JANUARY`,
`https://developer.android.com/reference/java/util/Calendar#DATE` = 1, etc.
This is important as there are variations in the Gregorian Calendar,
e.g. leap years have different days in the month = `https://developer.android.com/reference/java/util/Calendar#FEBRUARY`
so the result of `https://developer.android.com/reference/javax/xml/datatype/Duration#getMonths()` can be influenced.

Any remaining milliseconds after determining the year and month are discarded.

<br />

<br />

| Parameters ||
|---|---|
| `durationInMilliseconds` | `long`: Milliseconds of `Duration` to create. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/datatype/Duration` | New `Duration` created using the specified `durationInMilliseconds`. <br /> |

### newInstance

Added in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static DatatypeFactory newInstance (String factoryClassName, 
                ClassLoader classLoader)
```

Returns an instance of the named implementation of `DatatypeFactory`.

<br />

| Parameters ||
|---|---|
| `factoryClassName` | `String` <br /> |
| `classLoader` | `ClassLoader` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/javax/xml/datatype/DatatypeConfigurationException` | if `factoryClassName` is not available or cannot be instantiated. |

### newInstance

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static DatatypeFactory newInstance ()
```

<br />

Obtain a new instance of a `DatatypeFactory`.

The implementation resolution mechanisms are [defined](https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory#DatatypeFactory.newInstance) in this
`Class`'s documentation.

Note that you must supply your own implementation (such as Xerces); Android does not ship with a default implementation.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory` | New instance of a `DocumentBuilderFactory` <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/javax/xml/datatype/DatatypeConfigurationException` | If the implementation is not available or cannot be instantiated. |

### newXMLGregorianCalendar

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract XMLGregorianCalendar newXMLGregorianCalendar (String lexicalRepresentation)
```

<br />

Create a new XMLGregorianCalendar by parsing the String as a lexical representation.

Parsing the lexical string representation is defined in
[XML Schema 1.0 Part 2, Section 3.2.\[7-14\].1,
*Lexical Representation*.](http://www.w3.org/TR/xmlschema-2/#dateTime-order)

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:

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

Except for the noted lexical/canonical representation mismatches
listed in [XML Schema 1.0 errata, Section 3.2.7.2](http://www.w3.org/2001/05/xmlschema-errata#e2-45).

<br />

<br />

| Parameters ||
|---|---|
| `lexicalRepresentation` | `String`: Lexical representation of one the eight XML Schema date/time datatypes. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar` | `XMLGregorianCalendar` created from the `lexicalRepresentation`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If the `lexicalRepresentation` is not a valid `XMLGregorianCalendar`. |
| `https://developer.android.com/reference/java/lang/NullPointerException` | If `lexicalRepresentation` is `null`. |

### newXMLGregorianCalendar

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract XMLGregorianCalendar newXMLGregorianCalendar (GregorianCalendar cal)
```

<br />

Create an `XMLGregorianCalendar` from a `https://developer.android.com/reference/java/util/GregorianCalendar`.

| Field by Field Conversion from `https://developer.android.com/reference/java/util/GregorianCalendar` to an `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar` ||
| `java.util.GregorianCalendar` field | `javax.xml.datatype.XMLGregorianCalendar` field |
|:---:|---|
| `ERA == GregorianCalendar.BC ? -YEAR : YEAR` | `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar#setYear(int)` |
| `MONTH + 1` | `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar#setMonth(int)` |
| `DAY_OF_MONTH` | `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar#setDay(int)` |
| `HOUR_OF_DAY, MINUTE, SECOND, MILLISECOND` | `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar#setTime(int,%20int,%20int,%20java.math.BigDecimal)` |
| `(ZONE_OFFSET + DST_OFFSET) / (60*1000)` *(in minutes)* | `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar#setTimezone(int)`^*\**^ |

*\** 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 ||
|---|---|
| `cal` | `GregorianCalendar`: `java.util.GregorianCalendar` used to create `XMLGregorianCalendar` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar` | `XMLGregorianCalendar` created from `java.util.GregorianCalendar` <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | If `cal` is `null`. |

### newXMLGregorianCalendar

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

<br />

Constructor of value spaces that a
`java.util.GregorianCalendar` instance would need to convert to an
`XMLGregorianCalendar` instance.

`XMLGregorianCalendar eon` and
`fractionalSecond` are set to `null`

A `https://developer.android.com/reference/javax/xml/datatype/DatatypeConstants#FIELD_UNDEFINED` value indicates that field is not set.

<br />

<br />

| Parameters ||
|---|---|
| `year` | `int`: of `XMLGregorianCalendar` to be created. <br /> |
| `month` | `int`: of `XMLGregorianCalendar` to be created. <br /> |
| `day` | `int`: of `XMLGregorianCalendar` to be created. <br /> |
| `hour` | `int`: of `XMLGregorianCalendar` to be created. <br /> |
| `minute` | `int`: of `XMLGregorianCalendar` to be created. <br /> |
| `second` | `int`: of `XMLGregorianCalendar` to be created. <br /> |
| `millisecond` | `int`: of `XMLGregorianCalendar` to be created. <br /> |
| `timezone` | `int`: of `XMLGregorianCalendar` to be created. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar` | `XMLGregorianCalendar` created from specified values. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If any individual parameter's value is outside the maximum value constraint for the field as determined by the Date/Time Data Mapping table in `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar` or if the composite values constitute an invalid `XMLGregorianCalendar` instance as determined by `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar#isValid()`. |

### newXMLGregorianCalendar

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

<br />

Constructor allowing for complete value spaces allowed by
W3C XML Schema 1.0 recommendation for xsd:dateTime and related
builtin datatypes. Note that `year` parameter supports
arbitrarily large numbers and fractionalSecond has infinite
precision.

A `null` value indicates that field is not set.

<br />

<br />

| Parameters ||
|---|---|
| `year` | `BigInteger`: of `XMLGregorianCalendar` to be created. <br /> |
| `month` | `int`: of `XMLGregorianCalendar` to be created. <br /> |
| `day` | `int`: of `XMLGregorianCalendar` to be created. <br /> |
| `hour` | `int`: of `XMLGregorianCalendar` to be created. <br /> |
| `minute` | `int`: of `XMLGregorianCalendar` to be created. <br /> |
| `second` | `int`: of `XMLGregorianCalendar` to be created. <br /> |
| `fractionalSecond` | `BigDecimal`: of `XMLGregorianCalendar` to be created. <br /> |
| `timezone` | `int`: of `XMLGregorianCalendar` to be created. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar` | `XMLGregorianCalendar` created from specified values. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If any individual parameter's value is outside the maximum value constraint for the field as determined by the Date/Time Data Mapping table in `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar` or if the composite values constitute an invalid `XMLGregorianCalendar` instance as determined by `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar#isValid()`. |

### newXMLGregorianCalendar

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract XMLGregorianCalendar newXMLGregorianCalendar ()
```

<br />

Create a new instance of an `XMLGregorianCalendar`.

All date/time datatype fields set to `https://developer.android.com/reference/javax/xml/datatype/DatatypeConstants#FIELD_UNDEFINED` or null.

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar` | New `XMLGregorianCalendar` with all date/time datatype fields set to `https://developer.android.com/reference/javax/xml/datatype/DatatypeConstants#FIELD_UNDEFINED` or null. <br /> |

### newXMLGregorianCalendarDate

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

<br />

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

For example, an instance of `gYear` can be created invoking this factory
with `month` and `day` parameters set to
`https://developer.android.com/reference/javax/xml/datatype/DatatypeConstants#FIELD_UNDEFINED`.

A `https://developer.android.com/reference/javax/xml/datatype/DatatypeConstants#FIELD_UNDEFINED` value indicates that field is not set.

<br />

<br />

| Parameters ||
|---|---|
| `year` | `int`: of `XMLGregorianCalendar` to be created. <br /> |
| `month` | `int`: of `XMLGregorianCalendar` to be created. <br /> |
| `day` | `int`: of `XMLGregorianCalendar` to be created. <br /> |
| `timezone` | `int`: offset in minutes. `https://developer.android.com/reference/javax/xml/datatype/DatatypeConstants#FIELD_UNDEFINED` indicates optional field is not set. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar` | `XMLGregorianCalendar` created from parameter values. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If any individual parameter's value is outside the maximum value constraint for the field as determined by the Date/Time Data Mapping table in `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar` or if the composite values constitute an invalid `XMLGregorianCalendar` instance as determined by `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar#isValid()`. |

**See also:**

- `https://developer.android.com/reference/javax/xml/datatype/DatatypeConstants#FIELD_UNDEFINED`

### newXMLGregorianCalendarTime

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

<br />

Create a Java instance of XML Schema builtin datatype time.

A `null` value indicates that field is not set.

A `https://developer.android.com/reference/javax/xml/datatype/DatatypeConstants#FIELD_UNDEFINED` value indicates that field is not set.

<br />

<br />

| Parameters ||
|---|---|
| `hours` | `int`: number of hours <br /> |
| `minutes` | `int`: number of minutes <br /> |
| `seconds` | `int`: number of seconds <br /> |
| `fractionalSecond` | `BigDecimal`: value of `null` indicates that this optional field is not set. <br /> |
| `timezone` | `int`: offset in minutes. `https://developer.android.com/reference/javax/xml/datatype/DatatypeConstants#FIELD_UNDEFINED` indicates optional field is not set. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar` | `XMLGregorianCalendar` created from parameter values. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If any individual parameter's value is outside the maximum value constraint for the field as determined by the Date/Time Data Mapping table in `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar` or if the composite values constitute an invalid `XMLGregorianCalendar` instance as determined by `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar#isValid()`. |

**See also:**

- `https://developer.android.com/reference/javax/xml/datatype/DatatypeConstants#FIELD_UNDEFINED`

### newXMLGregorianCalendarTime

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

<br />

Create a Java instance of XML Schema builtin datatype time.

A `https://developer.android.com/reference/javax/xml/datatype/DatatypeConstants#FIELD_UNDEFINED` value indicates that field is not set.

<br />

<br />

| Parameters ||
|---|---|
| `hours` | `int`: number of hours <br /> |
| `minutes` | `int`: number of minutes <br /> |
| `seconds` | `int`: number of seconds <br /> |
| `milliseconds` | `int`: number of milliseconds <br /> |
| `timezone` | `int`: offset in minutes. `https://developer.android.com/reference/javax/xml/datatype/DatatypeConstants#FIELD_UNDEFINED` indicates optional field is not set. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar` | `XMLGregorianCalendar` created from parameter values. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If any individual parameter's value is outside the maximum value constraint for the field as determined by the Date/Time Data Mapping table in `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar` or if the composite values constitute an invalid `XMLGregorianCalendar` instance as determined by `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar#isValid()`. |

**See also:**

- `https://developer.android.com/reference/javax/xml/datatype/DatatypeConstants#FIELD_UNDEFINED`

### newXMLGregorianCalendarTime

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

<br />

Create a Java instance of XML Schema builtin datatype `time`.

A `https://developer.android.com/reference/javax/xml/datatype/DatatypeConstants#FIELD_UNDEFINED` value indicates that field is not set.

<br />

<br />

| Parameters ||
|---|---|
| `hours` | `int`: number of hours <br /> |
| `minutes` | `int`: number of minutes <br /> |
| `seconds` | `int`: number of seconds <br /> |
| `timezone` | `int`: offset in minutes. `https://developer.android.com/reference/javax/xml/datatype/DatatypeConstants#FIELD_UNDEFINED` indicates optional field is not set. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar` | `XMLGregorianCalendar` created from parameter values. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If any individual parameter's value is outside the maximum value constraint for the field as determined by the Date/Time Data Mapping table in `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar` or if the composite values constitute an invalid `XMLGregorianCalendar` instance as determined by `https://developer.android.com/reference/javax/xml/datatype/XMLGregorianCalendar#isValid()`. |

**See also:**

- `https://developer.android.com/reference/javax/xml/datatype/DatatypeConstants#FIELD_UNDEFINED`