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

org.javers.java8support.ZonedDateTimeTypeAdapter Maven / Gradle / Ivy

There is a newer version: 7.6.1
Show newest version
package org.javers.java8support;

import org.javers.core.json.BasicStringTypeAdapter;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author bartosz.walacik
 */
class ZonedDateTimeTypeAdapter extends BasicStringTypeAdapter {
    private static final DateTimeFormatter ISO_FORMAT = DateTimeFormatter.ISO_ZONED_DATE_TIME;

    @Override
    public String serialize(ZonedDateTime sourceValue) {
        return sourceValue.format(ISO_FORMAT);
    }

    @Override
    public ZonedDateTime deserialize(String serializedValue) {
        return ZonedDateTime.parse(serializedValue, ISO_FORMAT);
    }


    @Override
    public Class getValueType() {
        return ZonedDateTime.class;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy