HHH-18065 Truncate date related milliseconds from value passed to java.sql.Time
This commit is contained in:
parent
17fec64fd7
commit
75e1f17139
|
@ -102,7 +102,7 @@ public class CalendarDateJavaType extends AbstractTemporalJavaType<Calendar> {
|
||||||
return (X) new java.sql.Date( value.getTimeInMillis() );
|
return (X) new java.sql.Date( value.getTimeInMillis() );
|
||||||
}
|
}
|
||||||
if ( java.sql.Time.class.isAssignableFrom( type ) ) {
|
if ( java.sql.Time.class.isAssignableFrom( type ) ) {
|
||||||
return (X) new java.sql.Time( value.getTimeInMillis() );
|
return (X) new java.sql.Time( value.getTimeInMillis() % 86_400_000 );
|
||||||
}
|
}
|
||||||
if ( java.sql.Timestamp.class.isAssignableFrom( type ) ) {
|
if ( java.sql.Timestamp.class.isAssignableFrom( type ) ) {
|
||||||
return (X) new java.sql.Timestamp( value.getTimeInMillis() );
|
return (X) new java.sql.Timestamp( value.getTimeInMillis() );
|
||||||
|
|
|
@ -119,7 +119,7 @@ public class CalendarJavaType extends AbstractTemporalJavaType<Calendar> impleme
|
||||||
return (X) new java.sql.Date( value.getTimeInMillis() );
|
return (X) new java.sql.Date( value.getTimeInMillis() );
|
||||||
}
|
}
|
||||||
if ( java.sql.Time.class.isAssignableFrom( type ) ) {
|
if ( java.sql.Time.class.isAssignableFrom( type ) ) {
|
||||||
return (X) new java.sql.Time( value.getTimeInMillis() );
|
return (X) new java.sql.Time( value.getTimeInMillis() % 86_400_000 );
|
||||||
}
|
}
|
||||||
if ( java.sql.Timestamp.class.isAssignableFrom( type ) ) {
|
if ( java.sql.Timestamp.class.isAssignableFrom( type ) ) {
|
||||||
return (X) new java.sql.Timestamp( value.getTimeInMillis() );
|
return (X) new java.sql.Timestamp( value.getTimeInMillis() );
|
||||||
|
|
|
@ -104,7 +104,7 @@ public class CalendarTimeJavaType extends AbstractTemporalJavaType<Calendar> {
|
||||||
return (X) new java.sql.Date( value.getTimeInMillis() );
|
return (X) new java.sql.Date( value.getTimeInMillis() );
|
||||||
}
|
}
|
||||||
if ( java.sql.Time.class.isAssignableFrom( type ) ) {
|
if ( java.sql.Time.class.isAssignableFrom( type ) ) {
|
||||||
return (X) new java.sql.Time( value.getTimeInMillis() );
|
return (X) new java.sql.Time( value.getTimeInMillis() % 86_400_000 );
|
||||||
}
|
}
|
||||||
if ( java.sql.Timestamp.class.isAssignableFrom( type ) ) {
|
if ( java.sql.Timestamp.class.isAssignableFrom( type ) ) {
|
||||||
return (X) new java.sql.Timestamp( value.getTimeInMillis() );
|
return (X) new java.sql.Timestamp( value.getTimeInMillis() );
|
||||||
|
|
|
@ -125,7 +125,7 @@ public class DateJavaType extends AbstractTemporalJavaType<Date> implements Vers
|
||||||
if ( java.sql.Time.class.isAssignableFrom( type ) ) {
|
if ( java.sql.Time.class.isAssignableFrom( type ) ) {
|
||||||
final java.sql.Time rtn = value instanceof java.sql.Time
|
final java.sql.Time rtn = value instanceof java.sql.Time
|
||||||
? ( java.sql.Time ) value
|
? ( java.sql.Time ) value
|
||||||
: new java.sql.Time( value.getTime() );
|
: new java.sql.Time( value.getTime() % 86_400_000 );
|
||||||
return (X) rtn;
|
return (X) rtn;
|
||||||
}
|
}
|
||||||
if ( java.sql.Timestamp.class.isAssignableFrom( type ) ) {
|
if ( java.sql.Timestamp.class.isAssignableFrom( type ) ) {
|
||||||
|
|
|
@ -123,7 +123,7 @@ public class InstantJavaType extends AbstractTemporalJavaType<Instant>
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( java.sql.Time.class.isAssignableFrom( type ) ) {
|
if ( java.sql.Time.class.isAssignableFrom( type ) ) {
|
||||||
return (X) new java.sql.Time( instant.toEpochMilli() );
|
return (X) new java.sql.Time( instant.toEpochMilli() % 86_400_000 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Date.class.isAssignableFrom( type ) ) {
|
if ( Date.class.isAssignableFrom( type ) ) {
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class JdbcTimeJavaType extends AbstractTemporalJavaType<Date> {
|
||||||
if ( LocalTime.class.isAssignableFrom( type ) ) {
|
if ( LocalTime.class.isAssignableFrom( type ) ) {
|
||||||
final Time time = value instanceof java.sql.Time
|
final Time time = value instanceof java.sql.Time
|
||||||
? ( (java.sql.Time) value )
|
? ( (java.sql.Time) value )
|
||||||
: new java.sql.Time( value.getTime() );
|
: new java.sql.Time( value.getTime() % 86_400_000 );
|
||||||
final LocalTime localTime = time.toLocalTime();
|
final LocalTime localTime = time.toLocalTime();
|
||||||
final long millis = time.getTime() % 1000;
|
final long millis = time.getTime() % 1000;
|
||||||
if ( millis == 0 ) {
|
if ( millis == 0 ) {
|
||||||
|
@ -143,7 +143,7 @@ public class JdbcTimeJavaType extends AbstractTemporalJavaType<Date> {
|
||||||
if ( Time.class.isAssignableFrom( type ) ) {
|
if ( Time.class.isAssignableFrom( type ) ) {
|
||||||
return value instanceof Time
|
return value instanceof Time
|
||||||
? value
|
? value
|
||||||
: new Time( value.getTime() );
|
: new Time( value.getTime() % 86_400_000 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Date.class.isAssignableFrom( type ) ) {
|
if ( Date.class.isAssignableFrom( type ) ) {
|
||||||
|
@ -181,6 +181,14 @@ public class JdbcTimeJavaType extends AbstractTemporalJavaType<Date> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( value instanceof Time ) {
|
||||||
|
return (Date) value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( value instanceof Date ) {
|
||||||
|
return new Time( ( (Date) value ).getTime() % 86_400_000 );
|
||||||
|
}
|
||||||
|
|
||||||
if ( value instanceof LocalTime ) {
|
if ( value instanceof LocalTime ) {
|
||||||
final LocalTime localTime = (LocalTime) value;
|
final LocalTime localTime = (LocalTime) value;
|
||||||
final Time time = Time.valueOf( localTime );
|
final Time time = Time.valueOf( localTime );
|
||||||
|
@ -191,16 +199,12 @@ public class JdbcTimeJavaType extends AbstractTemporalJavaType<Date> {
|
||||||
return new Time( time.getTime() + DateTimeUtils.roundToPrecision( localTime.getNano(), 3 ) / 1000000 );
|
return new Time( time.getTime() + DateTimeUtils.roundToPrecision( localTime.getNano(), 3 ) / 1000000 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( value instanceof Date ) {
|
|
||||||
return (Date) value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( value instanceof Long ) {
|
if ( value instanceof Long ) {
|
||||||
return new Time( (Long) value );
|
return new Time( (Long) value );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( value instanceof Calendar ) {
|
if ( value instanceof Calendar ) {
|
||||||
return new Time( ( (Calendar) value ).getTimeInMillis() );
|
return new Time( ( (Calendar) value ).getTimeInMillis() % 86_400_000 );
|
||||||
}
|
}
|
||||||
|
|
||||||
throw unknownWrap( value.getClass() );
|
throw unknownWrap( value.getClass() );
|
||||||
|
|
|
@ -158,7 +158,7 @@ public class JdbcTimestampJavaType extends AbstractTemporalJavaType<Date> implem
|
||||||
if ( java.sql.Time.class.isAssignableFrom( type ) ) {
|
if ( java.sql.Time.class.isAssignableFrom( type ) ) {
|
||||||
return value instanceof java.sql.Time
|
return value instanceof java.sql.Time
|
||||||
? ( java.sql.Time ) value
|
? ( java.sql.Time ) value
|
||||||
: new java.sql.Time( value.getTime() );
|
: new java.sql.Time( value.getTime() % 86_400_000 );
|
||||||
}
|
}
|
||||||
|
|
||||||
throw unknownUnwrap( type );
|
throw unknownUnwrap( type );
|
||||||
|
|
Loading…
Reference in New Issue