XMLGregorianCalendar.ToGregorianCalendar Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
ToGregorianCalendar() |
Convert this |
ToGregorianCalendar(TimeZone, Locale, XMLGregorianCalendar) |
Convert this |
ToGregorianCalendar()
Convert this XMLGregorianCalendar
to a GregorianCalendar
.
[Android.Runtime.Register("toGregorianCalendar", "()Ljava/util/GregorianCalendar;", "GetToGregorianCalendarHandler")]
public abstract Java.Util.GregorianCalendar? ToGregorianCalendar ();
[<Android.Runtime.Register("toGregorianCalendar", "()Ljava/util/GregorianCalendar;", "GetToGregorianCalendarHandler")>]
abstract member ToGregorianCalendar : unit -> Java.Util.GregorianCalendar
Returns
- Attributes
Remarks
Convert this XMLGregorianCalendar
to a GregorianCalendar
.
When this
instance has an undefined field, this conversion relies on the java.util.GregorianCalendar
default for its corresponding field. A notable difference between XML Schema 1.0 date/time datatypes and java.util.GregorianCalendar
is that Timezone value is optional for date/time datatypes and it is a required field for java.util.GregorianCalendar
. See javadoc for java.util.TimeZone.getDefault()
on how the default is determined. To explicitly specify the TimeZone
instance, see #toGregorianCalendar(TimeZone, Locale, XMLGregorianCalendar)
.
<table border="2" rules="all" cellpadding="2"> <thead> <tr> <th align="center" colspan="2"> Field by Field Conversion from this class to java.util.GregorianCalendar
</th> </tr> </thead> <tbody> <tr> <td>java.util.GregorianCalendar
field</td> <td>javax.xml.datatype.XMLGregorianCalendar
field</td> </tr> <tr> <td>ERA
</td> <td>#getEonAndYear()
.signum() < 0 ? GregorianCalendar.BC : GregorianCalendar.AD
</td> </tr> <tr> <td>YEAR
</td> <td>#getEonAndYear()
.abs().intValue()
*</td> </tr> <tr> <td>MONTH
</td> <td>#getMonth()
- DatatypeConstants#JANUARY
+ GregorianCalendar#JANUARY
</td> </tr> <tr> <td>DAY_OF_MONTH
</td> <td>#getDay()
</td> </tr> <tr> <td>HOUR_OF_DAY
</td> <td>#getHour()
</td> </tr> <tr> <td>MINUTE
</td> <td>#getMinute()
</td> </tr> <tr> <td>SECOND
</td> <td>#getSecond()
</td> </tr> <tr> <td>MILLISECOND
</td> <td>get millisecond order from #getFractionalSecond()
*</td> </tr> <tr> <td>GregorianCalendar.setTimeZone(TimeZone)
</td> <td>#getTimezone()
formatted into Custom timezone id</td> </tr> </tbody> </table> * designates possible loss of precision during the conversion due to source datatype having higher precision than target datatype.
To ensure consistency in conversion implementations, the new GregorianCalendar
should be instantiated in following manner. <ul> <li>Using timeZone
value as defined above, create a new java.util.GregorianCalendar(timeZone,Locale.getDefault())
. </li> <li>Initialize all GregorianCalendar fields by calling {(
Java documentation for javax.xml.datatype.XMLGregorianCalendar.toGregorianCalendar()
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
See also
- <xref:Javax.Xml.Datatype.XMLGregorianCalendar.ToGregorianCalendar(Java.Util.TimeZone%2c+Java.Util.Locale%2c+Java.Util.Locale)>
Applies to
ToGregorianCalendar(TimeZone, Locale, XMLGregorianCalendar)
Convert this XMLGregorianCalendar
along with provided parameters
to a GregorianCalendar
instance.
[Android.Runtime.Register("toGregorianCalendar", "(Ljava/util/TimeZone;Ljava/util/Locale;Ljavax/xml/datatype/XMLGregorianCalendar;)Ljava/util/GregorianCalendar;", "GetToGregorianCalendar_Ljava_util_TimeZone_Ljava_util_Locale_Ljavax_xml_datatype_XMLGregorianCalendar_Handler")]
public abstract Java.Util.GregorianCalendar? ToGregorianCalendar (Java.Util.TimeZone? timezone, Java.Util.Locale? aLocale, Javax.Xml.Datatype.XMLGregorianCalendar? defaults);
[<Android.Runtime.Register("toGregorianCalendar", "(Ljava/util/TimeZone;Ljava/util/Locale;Ljavax/xml/datatype/XMLGregorianCalendar;)Ljava/util/GregorianCalendar;", "GetToGregorianCalendar_Ljava_util_TimeZone_Ljava_util_Locale_Ljavax_xml_datatype_XMLGregorianCalendar_Handler")>]
abstract member ToGregorianCalendar : Java.Util.TimeZone * Java.Util.Locale * Javax.Xml.Datatype.XMLGregorianCalendar -> Java.Util.GregorianCalendar
Parameters
- timezone
- TimeZone
provide Timezone. null
is a legal value.
- aLocale
- Locale
provide explicit Locale. Use default GregorianCalendar locale if
value is null
.
- defaults
- XMLGregorianCalendar
provide default field values to use when corresponding
field for this instance is FIELD_UNDEFINED or null.
If defaults
is null
or a field
within the specified defaults
is undefined,
just use java.util.GregorianCalendar
defaults.
Returns
a java.util.GregorianCalendar conversion of this instance.
- Attributes
Remarks
Convert this XMLGregorianCalendar
along with provided parameters to a GregorianCalendar
instance.
Since XML Schema 1.0 date/time datetypes has no concept of timezone ids or daylight savings timezone ids, this conversion operation allows the user to explicitly specify one with timezone
parameter.
To compute the return value's TimeZone
field, <ul> <li>when parameter timeZone
is non-null, it is the timezone field.</li> <li>else when this.getTimezone() != FIELD_UNDEFINED
, create a java.util.TimeZone
with a custom timezone id using the this.getTimezone()
.</li> <li>else when defaults.getTimezone() != FIELD_UNDEFINED
, create a java.util.TimeZone
with a custom timezone id using defaults.getTimezone()
.</li> <li>else use the GregorianCalendar
default timezone value for the host is defined as specified by java.util.TimeZone.getDefault()
.</li></ul>
To ensure consistency in conversion implementations, the new GregorianCalendar
should be instantiated in following manner. <ul> <li>Create a new java.util.GregorianCalendar(TimeZone, Locale)
with TimeZone set as specified above and the Locale
parameter. </li> <li>Initialize all GregorianCalendar fields by calling GregorianCalendar#clear()
</li> <li>Obtain a pure Gregorian Calendar by invoking GregorianCalendar.setGregorianChange( new Date(Long.MIN_VALUE))
.</li> <li>Its fields ERA, YEAR, MONTH, DAY_OF_MONTH, HOUR_OF_DAY, MINUTE, SECOND and MILLISECOND are set using the method Calendar.set(int,int)
</li> </ul>
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.