public <X> LocalDateTime wrap(X value, WrapperOptions options) {
if ( value == null ) {
return null;
}
if ( LocalDateTime.class.isInstance( value ) ) {
return (LocalDateTime) value;
}
if ( Timestamp.class.isInstance( value ) ) {
final Timestamp ts = (Timestamp) value;
/*
* Workaround for HHH-13266 (JDK-8061577).
* We used to do LocalDateTime.ofInstant( ts.toInstant(), ZoneId.systemDefault() ),
* but on top of being more complex than the line below, it won't always work.
* ts.toInstant() assumes the number of milliseconds since the epoch
* means the same thing in Timestamp and Instant, but it doesn't, in particular before 1900.
*/
return ts.toLocalDateTime();
}
if ( Long.class.isInstance( value ) ) {
final Instant instant = Instant.ofEpochMilli( (Long) value );
return LocalDateTime.ofInstant( instant, ZoneId.systemDefault() );
}
if ( Calendar.class.isInstance( value ) ) {
final Calendar calendar = (Calendar) value;
return LocalDateTime.ofInstant( calendar.toInstant(), calendar.getTimeZone().toZoneId() );
}
if ( Date.class.isInstance( value ) ) {
final Timestamp ts = (Timestamp) value;
final Instant instant = Instant.ofEpochMilli( ts.getTime() );
return LocalDateTime.ofInstant( instant, ZoneId.systemDefault() );
}
throw unknownWrap( value.getClass() );
}
ZeroDate's byte[19] = {48, 48, 48, 48, 45, 48, 48, 45, 48, 48, 32, 48, 48, 58, 48, 48, 58, 48, 48}