--- /dev/null
+package de.juplo.jpa.converters;
+
+import java.time.Duration;
+import javax.persistence.AttributeConverter;
+import javax.persistence.Converter;
+
+
+/**
+ * Converts a {@link Duration} into its {@link String} representation.
+ * @author Kai Moritz
+ */
+@Converter
+public class DurationConverter implements AttributeConverter<Duration, String>
+{
+ @Override
+ public String convertToDatabaseColumn(Duration duration)
+ {
+ return duration.toString();
+ }
+
+ @Override
+ public Duration convertToEntityAttribute(String string)
+ {
+ return Duration.parse(string);
+ }
+}
--- /dev/null
+package de.juplo.jpa.converters;
+
+import java.time.Period;
+import javax.persistence.AttributeConverter;
+import javax.persistence.Converter;
+
+
+/**
+ * Converts a {@link Period} into its {@link String} representation.
+ * @author Kai Moritz
+ */
+@Converter
+public class PeriodConverter implements AttributeConverter<Period, String>
+{
+ @Override
+ public String convertToDatabaseColumn(Period period)
+ {
+ return period.toString();
+ }
+
+ @Override
+ public Period convertToEntityAttribute(String string)
+ {
+ return Period.parse(string);
+ }
+}