org.javers.core.json.typeadapter.util.JavaSqlTimestampTypeAdapter 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.core.json.typeadapter.util;
import org.javers.core.json.BasicStringTypeAdapter;
import java.sql.Timestamp;
import java.time.LocalDateTime;
/**
* Serializes java.sql.Timestamp to JSON String using ISO util format yyyy-MM-dd'T'HH:mm:ss.SSS
*
* @author bartosz walacik
*/
class JavaSqlTimestampTypeAdapter extends BasicStringTypeAdapter {
@Override
public String serialize(Timestamp sourceValue) {
return UtilTypeCoreAdapters.serialize(sourceValue);
}
@Override
public Timestamp deserialize(String serializedValue) {
LocalDateTime date = UtilTypeCoreAdapters.deserializeLocalDateTime(serializedValue);
return java.sql.Timestamp.valueOf(date);
}
@Override
public Class getValueType() {
return Timestamp.class;
}
}