public class ZonedDateTimeAdapter
extends javax.xml.bind.annotation.adapters.XmlAdapter<java.lang.String,javax.xml.datatype.XMLGregorianCalendar>
Marshals the date time as a local time with UTC offset format YYYY-MM-DDThh:mm:ss[.sss]+/-hh:mm which is aligned with ISO 8601. Dislike the default jaxb implementation, this adapter will always print the offset, and for UTC times in particular an explicit '+00:00' offset is used instead of the 'Z'. The fractional seconds is printed only when it is different than zero.
Notice the configured adapter in the model is the IsoDateTimeAdapter
wrapper class, but you can pass this
default implementation or your own in the constructor.
TypeAdaptersConfiguration
Constructor and Description |
---|
ZonedDateTimeAdapter()
Creates a date time adapter with the default format
|
ZonedDateTimeAdapter(java.text.SimpleDateFormat dateFormat)
Creates a time adapter with a specific given format that will be used for both the marshalling and unmarshalling
|
ZonedDateTimeAdapter(javax.xml.bind.annotation.adapters.XmlAdapter<java.lang.String,javax.xml.datatype.XMLGregorianCalendar> customAdapterImpl)
Creates a date time adapter injecting a custom implementation
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
marshal(javax.xml.datatype.XMLGregorianCalendar cal)
Applies the configured format to the calendar.
|
javax.xml.datatype.XMLGregorianCalendar |
unmarshal(java.lang.String value)
Creates a calendar parsing the value with this adapter format, or the default lexical representation as fallback.
|
public ZonedDateTimeAdapter()
public ZonedDateTimeAdapter(java.text.SimpleDateFormat dateFormat)
public ZonedDateTimeAdapter(javax.xml.bind.annotation.adapters.XmlAdapter<java.lang.String,javax.xml.datatype.XMLGregorianCalendar> customAdapterImpl)
public javax.xml.datatype.XMLGregorianCalendar unmarshal(java.lang.String value) throws java.lang.Exception
unmarshal
in class javax.xml.bind.annotation.adapters.XmlAdapter<java.lang.String,javax.xml.datatype.XMLGregorianCalendar>
value
- the XML date time value to convertjava.lang.Exception
public java.lang.String marshal(javax.xml.datatype.XMLGregorianCalendar cal) throws java.lang.Exception
marshal
in class javax.xml.bind.annotation.adapters.XmlAdapter<java.lang.String,javax.xml.datatype.XMLGregorianCalendar>
cal
- the model calendar to marshaljava.lang.Exception