Class OffsetDateXmlAdapter
- java.lang.Object
-
- jakarta.xml.bind.annotation.adapters.XmlAdapter<String,OffsetDateTime>
-
- com.addicticks.texttime.jaxb.OffsetDateXmlAdapter
-
public class OffsetDateXmlAdapter extends jakarta.xml.bind.annotation.adapters.XmlAdapter<String,OffsetDateTime>
JAXB adapter to convert betweenxs:dateandOffsetDateTime.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
getZoneOffsetForDate(java.time.LocalDate)method.- See Also:
OffsetDateClassXmlAdapter
-
-
Constructor Summary
Constructors Constructor Description OffsetDateXmlAdapter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ZoneOffsetgetZoneOffsetForDate(LocalDate localDate)Gets ZoneOffset for a givenLocalDatevalue.Stringmarshal(OffsetDateTime v)Converts toxs:dateformat.OffsetDateTimeunmarshal(String v)Converts fromxs:dateformat.
-
-
-
Method Detail
-
unmarshal
public final OffsetDateTime unmarshal(String v)
Converts fromxs:dateformat. The returned OffsetDateTime value will have the time part set to midnight.A number of minor deviations from the standard are accepted while parsing. See
DateTimeFormatterXSD.XSD_DATE_PARSERfor more information.- Specified by:
unmarshalin classjakarta.xml.bind.annotation.adapters.XmlAdapter<String,OffsetDateTime>
-
marshal
public final String marshal(OffsetDateTime v)
Converts toxs:dateformat. Any time value on the input will be ignored, only the date part and the offset will be used to produce the output.- Specified by:
marshalin classjakarta.xml.bind.annotation.adapters.XmlAdapter<String,OffsetDateTime>
-
getZoneOffsetForDate
public ZoneOffset getZoneOffsetForDate(LocalDate localDate)
Gets ZoneOffset for a givenLocalDatevalue. Sub-classes may override this.This method is needed because the XML Schema
datedata 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 oflocalDate+ current-LocalTime.- Parameters:
localDate-- Returns:
- offset to use when none is present in XML input data, never null
-
-