1 package de.juplo.jpa.converters;
3 import java.sql.Timestamp;
4 import java.time.LocalDateTime;
5 import javax.persistence.AttributeConverter;
6 import javax.persistence.Converter;
10 * Converts a {@link LocalDateTime} to a {@link Timestamp}.
13 @Converter(autoApply = true)
14 public class LocalDateTimeConverter implements AttributeConverter<LocalDateTime, Timestamp>
17 public Timestamp convertToDatabaseColumn(LocalDateTime ldt)
19 return Timestamp.valueOf(ldt);
23 public LocalDateTime convertToEntityAttribute(Timestamp ts)
25 return ts.toLocalDateTime();