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

pro.fessional.wings.silencer.jaxb.LocalDateTimeXmlAdapter 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.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author trydofor
 * @since 2021-04-19
 */
public class LocalDateTimeXmlAdapter extends XmlAdapter {
    @Override
    public LocalDateTime unmarshal(String stringValue) {
        return stringValue != null ? DateParser.parseDateTime(stringValue) : null;
    }

    @Override
    public String marshal(LocalDateTime value) {
        return value != null ? value.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME) : null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy