Class OffsetDateClassXmlAdapter
- java.lang.Object
-
- jakarta.xml.bind.annotation.adapters.XmlAdapter<String,OffsetDate>
-
- com.addicticks.texttime.jaxb.OffsetDateClassXmlAdapter
-
public class OffsetDateClassXmlAdapter extends jakarta.xml.bind.annotation.adapters.XmlAdapter<String,OffsetDate>
JAXB adapter to convert betweenxs:dateand custom classOffsetDate.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:
OffsetDateXmlAdapter
-
-
Constructor Summary
Constructors Constructor Description OffsetDateClassXmlAdapter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ZoneOffsetgetZoneOffsetForDate(LocalDate localDate)Gets ZoneOffset for a givenLocalDatevalue.Stringmarshal(OffsetDate v)Converts toxs:dateformat.OffsetDateunmarshal(String v)Converts fromxs:dateformat.
-
-
-
Method Detail
-
unmarshal
public final OffsetDate unmarshal(String v)
Converts fromxs:dateformat.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,OffsetDate>
-
marshal
public final String marshal(OffsetDate v)
Converts toxs:dateformat.- Specified by:
marshalin classjakarta.xml.bind.annotation.adapters.XmlAdapter<String,OffsetDate>
-
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
-
-