1 package de.juplo.jpa.converters;
4 import java.time.OffsetTime;
5 import java.time.ZoneOffset;
6 import javax.persistence.AttributeConverter;
7 import javax.persistence.Converter;
11 * Converts an {@link OffsetTime} to a {@link Time}.
14 @Converter(autoApply = true)
15 public class OffsetTimeConverter implements AttributeConverter<OffsetTime, Time>
18 public Time convertToDatabaseColumn(OffsetTime ot)
20 ZoneOffset offset = ot.getOffset();
21 return Time.valueOf(ot.withOffsetSameInstant(ZoneOffset.UTC).toLocalTime());
25 public OffsetTime convertToEntityAttribute(Time time)
27 return OffsetTime.of(time.toLocalTime(), ZoneOffset.UTC);