From d4b509f020ad436b5b0bab70ab32a9ab78953fe2 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Mon, 21 Dec 2015 21:39:19 +0100 Subject: [PATCH] Implemented a ZoneID-to-String converter --- .../juplo/jpa/converters/ZoneIdConverter.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/main/java/de/juplo/jpa/converters/ZoneIdConverter.java 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); + } +} -- 2.20.1