From 4e9789bdff7314640be64ca567503c6b118792c6 Mon Sep 17 00:00:00 2001 From: Jan Schatteman Date: Fri, 26 May 2023 00:49:26 +0200 Subject: [PATCH] HHH-16686 - Fix for bug in LocalTimeJavaType.unwrap() Signed-off-by: Jan Schatteman --- .../org/hibernate/type/descriptor/java/JdbcTimeJavaType.java | 2 +- .../org/hibernate/type/descriptor/java/LocalTimeJavaType.java | 2 +- .../org/hibernate/type/descriptor/java/OffsetTimeJavaType.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/JdbcTimeJavaType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/JdbcTimeJavaType.java index 9e469cd118..f83a1845b3 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/JdbcTimeJavaType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/JdbcTimeJavaType.java @@ -188,7 +188,7 @@ public class JdbcTimeJavaType extends AbstractTemporalJavaType { return time; } // Preserve milliseconds, which java.sql.Time supports - return new Time( time.getTime() + DateTimeUtils.roundToPrecision( localTime.getNano(), 3 ) ); + return new Time( time.getTime() + DateTimeUtils.roundToPrecision( localTime.getNano(), 3 ) / 1000000 ); } if ( value instanceof Date ) { diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/LocalTimeJavaType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/LocalTimeJavaType.java index b1d7206bba..e245fb3cfa 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/LocalTimeJavaType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/LocalTimeJavaType.java @@ -88,7 +88,7 @@ public class LocalTimeJavaType extends AbstractTemporalJavaType { return (X) time; } // Preserve milliseconds, which java.sql.Time supports - return (X) new Time( time.getTime() + DateTimeUtils.roundToPrecision( value.getNano(), 3 ) ); + return (X) new Time( time.getTime() + DateTimeUtils.roundToPrecision( value.getNano(), 3 ) / 1000000 ); } // Oracle documentation says to set the Date to January 1, 1970 when convert from diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/OffsetTimeJavaType.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/OffsetTimeJavaType.java index 0577c7f109..1d949cdd0a 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/OffsetTimeJavaType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/OffsetTimeJavaType.java @@ -105,7 +105,7 @@ public class OffsetTimeJavaType extends AbstractTemporalJavaType { return (X) time; } // Preserve milliseconds, which java.sql.Time supports - return (X) new Time( time.getTime() + DateTimeUtils.roundToPrecision( jdbcOffsetTime.getNano(), 3 ) ); + return (X) new Time( time.getTime() + DateTimeUtils.roundToPrecision( jdbcOffsetTime.getNano(), 3 ) / 1000000 ); } final OffsetDateTime jdbcOffsetDateTime = jdbcOffsetTime.atDate( LocalDate.EPOCH );