pro.fessional.wings.silencer.jaxb.LocalDateXmlAdapter Maven / Gradle / Ivy
The newest version!
package pro.fessional.wings.silencer.jaxb;
import jakarta.xml.bind.annotation.adapters.XmlAdapter;
import pro.fessional.mirana.time.DateParser;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
/**
* @author trydofor
* @since 2021-04-19
*/
public class LocalDateXmlAdapter extends XmlAdapter {
@Override
public LocalDate unmarshal(String stringValue) {
return stringValue != null ? DateParser.parseDate(stringValue) : null;
}
@Override
public String marshal(LocalDate value) {
return value != null ? value.format(DateTimeFormatter.ISO_LOCAL_DATE) : null;
}
}