com.mantledillusion.metrics.trail.ZoneIdStringAttributeConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of trail-metrics-adaptor-jpa Show documentation
Show all versions of trail-metrics-adaptor-jpa Show documentation
JPA based database adaptor for the trail-metrics-api.
package com.mantledillusion.metrics.trail;
import javax.persistence.AttributeConverter;
import java.time.ZoneId;
/**
* JPA {@link AttributeConverter} to convert a {@link ZoneId} to {@link String} and vice versa.
*/
public class ZoneIdStringAttributeConverter implements AttributeConverter {
@Override
public String convertToDatabaseColumn(ZoneId attribute) {
return attribute.getId();
}
@Override
public ZoneId convertToEntityAttribute(String dbData) {
return ZoneId.of(dbData);
}
}