@LastModifiedDate
@Convert(converter = LocalDateTime2TimestampConverter.class)
@Slf4j
public class LocalDateTime2TimestampConverter implements
AttributeConverter<LocalDateTime, Timestamp> {
@Override
public Timestamp convertToDatabaseColumn(LocalDateTime ld) {
return ld == null ? null : new Timestamp(ld.toDateTime().getMillis());
}
@Override
public LocalDateTime convertToEntityAttribute(Timestamp ts) {
if (ts != null) {
try {
return LocalDateTime.fromDateFields(ts);
} catch (IllegalArgumentException ex) {
log.warn("Can't convert {} to LocalDate", ts, ex);
}
}
return null;
}
}