Class OffsetDateTimeXmlAdapter
- java.lang.Object
-
- jakarta.xml.bind.annotation.adapters.XmlAdapter<String,OffsetDateTime>
-
- com.addicticks.texttime.jaxb.OffsetDateTimeXmlAdapter
-
public class OffsetDateTimeXmlAdapter extends jakarta.xml.bind.annotation.adapters.XmlAdapter<String,OffsetDateTime>
JAXB adapter to convert betweenxs:dateTimeandOffsetDateTime.If the adapter is used for unmarshalling (parsing XML to object) and there is no zone offset in the input data then it may be needed to extend this class and customize the
getZoneOffsetForDateTime(java.time.LocalDateTime)method.
-
-
Constructor Summary
Constructors Constructor Description OffsetDateTimeXmlAdapter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ZoneOffsetgetZoneOffsetForDateTime(LocalDateTime localDateTime)Gets ZoneOffset for a givenLocalDateTimevalue.Stringmarshal(OffsetDateTime v)Converts toxs:dateTimeformat.OffsetDateTimeunmarshal(String v)Converts fromxs:dateTimeformat.
-
-
-
Method Detail
-
unmarshal
public final OffsetDateTime unmarshal(String v)
Converts fromxs:dateTimeformat.A number of minor deviations from the standard are accepted while parsing. See
DateTimeFormatterXSD.XSD_DATETIME_PARSERfor more information.If there are more than 9 fractional digits on the second value then digits after the 9th digit will be ignored.
- Specified by:
unmarshalin classjakarta.xml.bind.annotation.adapters.XmlAdapter<String,OffsetDateTime>
-
marshal
public final String marshal(OffsetDateTime v)
Converts toxs:dateTimeformat.- Specified by:
marshalin classjakarta.xml.bind.annotation.adapters.XmlAdapter<String,OffsetDateTime>
-
getZoneOffsetForDateTime
public ZoneOffset getZoneOffsetForDateTime(LocalDateTime localDateTime)
Gets ZoneOffset for a givenLocalDateTimevalue. Sub-classes may override this.This method is needed because the XML Schema
dateTimedata type allows to leave out the offset. Therefore, when unmarshalling there may be no offset in the input data. If this is the case then this method will be called. In summary, the method is only called when unmarshalling and only when input data has no offset.The default implementation uses the the system's default zone id (from
ZoneId.systemDefault()) and then finds the appropriate offset for that zone given a point in time oflocalDateTime.- Parameters:
localDateTime-- Returns:
- offset to use when none is present in XML input data, never null
-
-