net.optionfactory.spring.marshaling.jaxb.time.XsdDateTimeToOffsetDateTime Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of marshaling-jaxb Show documentation
Show all versions of marshaling-jaxb Show documentation
optionfactory-spring jaxb time adapters
package net.optionfactory.spring.marshaling.jaxb.time;
import jakarta.xml.bind.annotation.adapters.XmlAdapter;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
public class XsdDateTimeToOffsetDateTime extends XmlAdapter {
public static final DateTimeFormatter FORMAT = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
@Override
public OffsetDateTime unmarshal(String value) {
return value == null ? null : OffsetDateTime.parse(value, FORMAT);
}
@Override
public String marshal(OffsetDateTime v) {
return v == null ? null : FORMAT.format(v);
}
}