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

nl.vpro.xml.bind.InstantNoOmmitMillisXmlAdapter Maven / Gradle / Ivy

package nl.vpro.xml.bind;

import java.time.Instant;

import jakarta.xml.bind.annotation.adapters.XmlAdapter;

import nl.vpro.util.TimeUtils;

import static nl.vpro.xml.bind.InstantXmlAdapter.formatWithMillis;

/**
 * Like {@link InstantXmlAdapter}, but never omit millis. So no need for the thread local
 * @since 1.75
 */
public class InstantNoOmmitMillisXmlAdapter extends XmlAdapter {


    @Override
    public Instant unmarshal(String dateValue) {
        return TimeUtils.parse(dateValue).orElse(null);
    }

    @Override
    public String marshal(Instant value) {
       return formatWithMillis(value);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy