org.javers.java8support.OffsetDateTimeTypeAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javers-core Show documentation
Show all versions of javers-core Show documentation
JaVers - object auditing and diff framework for Java
package org.javers.java8support;
import org.javers.core.json.BasicStringTypeAdapter;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
/**
* @author bartosz.walacik
*/
class OffsetDateTimeTypeAdapter extends BasicStringTypeAdapter {
private static final DateTimeFormatter ISO_FORMAT = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
@Override
public String serialize(OffsetDateTime sourceValue) {
return sourceValue.format(ISO_FORMAT);
}
@Override
public OffsetDateTime deserialize(String serializedValue) {
return OffsetDateTime.parse(serializedValue, ISO_FORMAT);
}
@Override
public Class getValueType() {
return OffsetDateTime.class;
}
}