Class ZonedDateTimeConverter
- java.lang.Object
-
- google.registry.persistence.converter.ZonedDateTimeConverter
-
- All Implemented Interfaces:
javax.persistence.AttributeConverter<java.time.ZonedDateTime,java.sql.Timestamp>
public class ZonedDateTimeConverter extends java.lang.Object implements javax.persistence.AttributeConverter<java.time.ZonedDateTime,java.sql.Timestamp>
JPA converter to for storing/retrievingZonedDateTime
objects.Hibernate provides a default converter for
ZonedDateTime
, but it converts timestamp to a non-normalized format, e.g., 2019-09-01T01:01:01Z will be converted to 2019-09-01T01:01:01Z[UTC]. This converter solves that problem by explicitly callingZoneId.normalized()
to normalize the zone id.
-
-
Constructor Summary
Constructors Constructor Description ZonedDateTimeConverter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.sql.Timestamp
convertToDatabaseColumn(java.time.ZonedDateTime attribute)
java.time.ZonedDateTime
convertToEntityAttribute(java.sql.Timestamp dbData)
-
-
-
Method Detail
-
convertToDatabaseColumn
@Nullable public java.sql.Timestamp convertToDatabaseColumn(@Nullable java.time.ZonedDateTime attribute)
- Specified by:
convertToDatabaseColumn
in interfacejavax.persistence.AttributeConverter<java.time.ZonedDateTime,java.sql.Timestamp>
-
convertToEntityAttribute
@Nullable public java.time.ZonedDateTime convertToEntityAttribute(@Nullable java.sql.Timestamp dbData)
- Specified by:
convertToEntityAttribute
in interfacejavax.persistence.AttributeConverter<java.time.ZonedDateTime,java.sql.Timestamp>
-
-