All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.inugami.commons.marshaling.jaxb.LocalDateTimeAdapter Maven / Gradle / Ivy

There is a newer version: 3.3.5
Show newest version
package io.inugami.commons.marshaling.jaxb;

import javax.xml.bind.annotation.adapters.XmlAdapter;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class LocalDateTimeAdapter extends XmlAdapter implements JaxbAdapterSpi {
    @Override
    public LocalDateTime unmarshal(final String value) throws Exception {
        return LocalDateTime.parse(value);
    }

    @Override
    public String marshal(final LocalDateTime value) throws Exception {
        return value == null ? null : value.format(DateTimeFormatter.ISO_DATE_TIME);
    }


    @Override
    public XmlAdapter getAdapter() {
        return this;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy