net.optionfactory.spring.marshaling.jaxb.time.XsdDateToLocalDate 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.LocalDate;
import java.time.format.DateTimeFormatter;
public class XsdDateToLocalDate extends XmlAdapter {
public static final DateTimeFormatter FORMAT = DateTimeFormatter.ISO_DATE;
@Override
public LocalDate unmarshal(String value) {
return value == null ? null : LocalDate.parse(value, FORMAT);
}
@Override
public String marshal(LocalDate v) {
return v == null ? null : FORMAT.format(v);
}
}