org.javers.core.json.typeadapter.util.JavaUtilDateTypeAdapter 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.util.Date;
/**
* Serializes java.util.Date to JSON String using ISO util format yyyy-MM-dd'T'HH:mm:ss.SSS
*
* @author bartosz walacik
*/
class JavaUtilDateTypeAdapter extends BasicStringTypeAdapter {
@Override
public String serialize(Date sourceValue) {
return UtilTypeCoreAdapters.serialize(sourceValue);
}
@Override
public Date deserialize(String serializedValue) {
return new Date(java.util.Date.from(UtilTypeCoreAdapters.deserializeToInstant(serializedValue)).getTime());
}
@Override
public Class getValueType() {
return Date.class;
}
}