Class DurationConverter

  • All Implemented Interfaces:
    javax.persistence.AttributeConverter<org.joda.time.Duration,​org.postgresql.util.PGInterval>

    public class DurationConverter
    extends java.lang.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.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.postgresql.util.PGInterval convertToDatabaseColumn​(org.joda.time.Duration duration)  
      org.joda.time.Duration convertToEntityAttribute​(org.postgresql.util.PGInterval dbData)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DurationConverter

        public DurationConverter()
    • Method Detail

      • convertToDatabaseColumn

        @Nullable
        public org.postgresql.util.PGInterval convertToDatabaseColumn​(@Nullable
                                                                      org.joda.time.Duration duration)
        Specified by:
        convertToDatabaseColumn in interface javax.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 interface javax.persistence.AttributeConverter<org.joda.time.Duration,​org.postgresql.util.PGInterval>