From: Kai Moritz Date: Mon, 21 Dec 2015 20:39:19 +0000 (+0100) Subject: Implemented a ZoneID-to-String converter X-Git-Tag: jpa-converters-1.0.0~27 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=d4b509f020ad436b5b0bab70ab32a9ab78953fe2;p=jpa-converters Implemented a ZoneID-to-String converter --- diff --git a/src/main/java/de/juplo/jpa/converters/ZoneIdConverter.java b/src/main/java/de/juplo/jpa/converters/ZoneIdConverter.java new file mode 100644 index 0000000..57f3ba1 --- /dev/null +++ b/src/main/java/de/juplo/jpa/converters/ZoneIdConverter.java @@ -0,0 +1,26 @@ +package de.juplo.jpa.converters; + +import java.time.ZoneId; +import javax.persistence.AttributeConverter; +import javax.persistence.Converter; + + +/** + * Converts a {@link ZoneID} to its string-representation as ID. + * @author Kai Moritz + */ +@Converter(autoApply = true) +public class ZoneIdConverter implements AttributeConverter +{ + @Override + public String convertToDatabaseColumn(ZoneId zone) + { + return zone.getId(); + } + + @Override + public ZoneId convertToEntityAttribute(String string) + { + return ZoneId.of(string); + } +}