@Override public void nullSafeSet( PreparedStatement preparedStatement, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { if (value == null) { StandardBasicTypes.DATE.nullSafeSet(preparedStatement, null, index, session); } else { LocalDate ld = ((LocalDate) value); Instant instant = ld.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant(); Date time = Date.from(instant); StandardBasicTypes.DATE.nullSafeSet(preparedStatement, time, index, session); } }
@Override public Object nullSafeGet( ResultSet resultSet, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { Object timestamp = StandardBasicTypes.DATE.nullSafeGet(resultSet, names, session, owner); if (timestamp == null) { return null; } Date date = (Date) timestamp; Instant instant = Instant.ofEpochMilli(date.getTime()); return LocalDateTime.ofInstant(instant, ZoneId.systemDefault()).toLocalDate(); }