HHH-10371 - LocalDate value changes after fetching the row from the database

This commit is contained in:
Andrea Boriero 2015-12-14 21:44:48 +00:00
parent 55ce22a740
commit 0e7dfa1935
1 changed files with 7 additions and 3 deletions

View File

@ -111,11 +111,15 @@ public class LocalDateJavaDescriptor extends AbstractTypeDescriptor<LocalDate> {
} }
if ( Date.class.isInstance( value ) ) { if ( Date.class.isInstance( value ) ) {
final Date ts = (Date) value; if ( java.sql.Date.class.isInstance( value ) ) {
final Instant instant = Instant.ofEpochMilli( ts.getTime() ); return ((java.sql.Date) value).toLocalDate();
return LocalDateTime.ofInstant( instant, ZoneId.systemDefault() ).toLocalDate(); }
else {
return Instant.ofEpochMilli( ((Date) value).getTime() ).atZone( ZoneId.systemDefault() ).toLocalDate();
}
} }
throw unknownWrap( value.getClass() ); throw unknownWrap( value.getClass() );
} }
} }