Class DurationConverter
java.lang.Object
google.registry.persistence.converter.DurationConverter
- All Implemented Interfaces:
javax.persistence.AttributeConverter<org.joda.time.Duration,
org.postgresql.util.PGInterval>
public class DurationConverter
extends Object
implements javax.persistence.AttributeConverter<org.joda.time.Duration,org.postgresql.util.PGInterval>
JPA converter to for storing/retrieving
Duration
objects.
The Joda Time Duration is simply a number of milliseconds representing a length of time. This can be converted into a PGInterval, but only for the fields that have a standard number of milliseconds. Therefore, there is no way to populate the months or years field of a PGInterval and be confident that it is representing the exact number of milliseconds it was intended to represent.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.postgresql.util.PGInterval
convertToDatabaseColumn
(org.joda.time.Duration duration) org.joda.time.Duration
convertToEntityAttribute
(org.postgresql.util.PGInterval dbData)
-
Constructor Details
-
DurationConverter
public DurationConverter()
-
-
Method Details
-
convertToDatabaseColumn
@Nullable public org.postgresql.util.PGInterval convertToDatabaseColumn(@Nullable org.joda.time.Duration duration) - Specified by:
convertToDatabaseColumn
in interfacejavax.persistence.AttributeConverter<org.joda.time.Duration,
org.postgresql.util.PGInterval>
-
convertToEntityAttribute
@Nullable public org.joda.time.Duration convertToEntityAttribute(@Nullable org.postgresql.util.PGInterval dbData) - Specified by:
convertToEntityAttribute
in interfacejavax.persistence.AttributeConverter<org.joda.time.Duration,
org.postgresql.util.PGInterval>
-