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 501f1948a2
commit 7f1bf8f3f7
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 ) ) {
final Date ts = (Date) value;
final Instant instant = Instant.ofEpochMilli( ts.getTime() );
return LocalDateTime.ofInstant( instant, ZoneId.systemDefault() ).toLocalDate();
if ( java.sql.Date.class.isInstance( value ) ) {
return ((java.sql.Date) value).toLocalDate();
}
else {
return Instant.ofEpochMilli( ((Date) value).getTime() ).atZone( ZoneId.systemDefault() ).toLocalDate();
}
}
throw unknownWrap( value.getClass() );
}
}