--- /dev/null
+package de.juplo.jpa.converters;
+
+import java.time.Duration;
+import java.time.temporal.ChronoUnit;
+import java.time.temporal.TemporalAmount;
+import javax.persistence.AttributeConverter;
+import javax.persistence.Converter;
+
+
+/**
+ * Converts a {@link TemporalAmount} into a {@link Long} representing
+ * milliseconds.
+ * @author Kai Moritz
+ */
+@Converter
+public class TemporalAmountToMillisConverter implements AttributeConverter<TemporalAmount, Long>
+{
+ @Override
+ public Long convertToDatabaseColumn(TemporalAmount amount)
+ {
+ return amount.get(ChronoUnit.MILLIS);
+ }
+
+ @Override
+ public TemporalAmount convertToEntityAttribute(Long millis)
+ {
+ return Duration.ofMillis(millis);
+ }
+}