diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/timezones/AutoZonedTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/timezones/AutoZonedTest.java index 421fd7deb3..a48d402ead 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/timezones/AutoZonedTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/timezones/AutoZonedTest.java @@ -1,5 +1,6 @@ package org.hibernate.orm.test.timezones; +import java.time.Instant; import java.time.OffsetDateTime; import java.time.ZoneId; import java.time.ZoneOffset; @@ -53,13 +54,17 @@ public class AutoZonedTest { scope.inSession( s -> { Zoned z = s.find(Zoned.class, id); final Dialect dialect = scope.getSessionFactory().getJdbcServices().getDialect(); + Instant expected = DateTimeUtils.adjustToDefaultPrecision( nowZoned.toInstant(), dialect ); + Instant actual = DateTimeUtils.adjustToDefaultPrecision( z.zonedDateTime.toInstant(), dialect ); assertEquals( - DateTimeUtils.roundToDefaultPrecision( nowZoned.toInstant(), dialect ), - DateTimeUtils.roundToDefaultPrecision( z.zonedDateTime.toInstant(), dialect ) + expected, + actual ); + expected = DateTimeUtils.adjustToDefaultPrecision( nowOffset.toInstant(), dialect ); + actual = DateTimeUtils.adjustToDefaultPrecision( z.offsetDateTime.toInstant(), dialect ); assertEquals( - DateTimeUtils.roundToDefaultPrecision( nowOffset.toInstant(), dialect ), - DateTimeUtils.roundToDefaultPrecision( z.offsetDateTime.toInstant(), dialect ) + expected, + actual ); assertEquals( nowZoned.toOffsetDateTime().getOffset(), z.zonedDateTime.toOffsetDateTime().getOffset() ); assertEquals( nowOffset.getOffset(), z.offsetDateTime.getOffset() ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/timezones/ColumnZonedTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/timezones/ColumnZonedTest.java index dbbcb3a62e..40336db540 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/timezones/ColumnZonedTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/timezones/ColumnZonedTest.java @@ -1,5 +1,6 @@ package org.hibernate.orm.test.timezones; +import java.time.Instant; import java.time.OffsetDateTime; import java.time.ZoneId; import java.time.ZoneOffset; @@ -53,13 +54,17 @@ public class ColumnZonedTest { scope.inSession( s -> { Zoned z = s.find(Zoned.class, id); final Dialect dialect = scope.getSessionFactory().getJdbcServices().getDialect(); + Instant expected = DateTimeUtils.adjustToDefaultPrecision( nowZoned.toInstant(), dialect ); + Instant actual = DateTimeUtils.adjustToDefaultPrecision( z.zonedDateTime.toInstant(), dialect ); assertEquals( - DateTimeUtils.roundToDefaultPrecision( nowZoned.toInstant(), dialect ), - DateTimeUtils.roundToDefaultPrecision( z.zonedDateTime.toInstant(), dialect ) + expected, + actual ); + expected = DateTimeUtils.adjustToDefaultPrecision( nowOffset.toInstant(), dialect ); + actual = DateTimeUtils.adjustToDefaultPrecision( z.offsetDateTime.toInstant(), dialect ); assertEquals( - DateTimeUtils.roundToDefaultPrecision( nowOffset.toInstant(), dialect ), - DateTimeUtils.roundToDefaultPrecision( z.offsetDateTime.toInstant(), dialect ) + expected, + actual ); assertEquals( nowZoned.toOffsetDateTime().getOffset(), z.zonedDateTime.toOffsetDateTime().getOffset() ); assertEquals( nowOffset.getOffset(), z.offsetDateTime.getOffset() ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/timezones/DefaultZonedTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/timezones/DefaultZonedTest.java index 0bb8a1f3b2..88a4123162 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/timezones/DefaultZonedTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/timezones/DefaultZonedTest.java @@ -1,5 +1,6 @@ package org.hibernate.orm.test.timezones; +import java.time.Instant; import java.time.OffsetDateTime; import java.time.ZoneId; import java.time.ZoneOffset; @@ -50,13 +51,17 @@ public class DefaultZonedTest { scope.inSession( s -> { Zoned z = s.find(Zoned.class, id); final Dialect dialect = scope.getSessionFactory().getJdbcServices().getDialect(); + Instant expected = DateTimeUtils.adjustToDefaultPrecision( nowZoned.toInstant(), dialect ); + Instant actual = DateTimeUtils.adjustToDefaultPrecision( z.zonedDateTime.toInstant(), dialect ); assertEquals( - DateTimeUtils.roundToDefaultPrecision( nowZoned.toInstant(), dialect ), - DateTimeUtils.roundToDefaultPrecision( z.zonedDateTime.toInstant(), dialect ) + expected, + actual ); + expected = DateTimeUtils.adjustToDefaultPrecision( nowOffset.toInstant(), dialect ); + actual = DateTimeUtils.adjustToDefaultPrecision( z.offsetDateTime.toInstant(), dialect ); assertEquals( - DateTimeUtils.roundToDefaultPrecision( nowOffset.toInstant(), dialect ), - DateTimeUtils.roundToDefaultPrecision( z.offsetDateTime.toInstant(), dialect ) + expected, + actual ); if ( dialect.getTimeZoneSupport() == TimeZoneSupport.NATIVE ) { assertEquals( nowZoned.toOffsetDateTime().getOffset(), z.zonedDateTime.toOffsetDateTime().getOffset() ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/timezones/JDBCTimeZoneZonedTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/timezones/JDBCTimeZoneZonedTest.java index f77bc9ced6..7e8c82913e 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/timezones/JDBCTimeZoneZonedTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/timezones/JDBCTimeZoneZonedTest.java @@ -57,13 +57,17 @@ public class JDBCTimeZoneZonedTest { ZoneId systemZone = ZoneId.systemDefault(); ZoneOffset systemOffset = systemZone.getRules().getOffset( Instant.now() ); final Dialect dialect = scope.getSessionFactory().getJdbcServices().getDialect(); + Instant expected = DateTimeUtils.adjustToDefaultPrecision( nowZoned.toInstant(), dialect ); + Instant actual = DateTimeUtils.adjustToDefaultPrecision( z.zonedDateTime.toInstant(), dialect ); assertEquals( - DateTimeUtils.roundToDefaultPrecision( nowZoned.toInstant(), dialect ), - DateTimeUtils.roundToDefaultPrecision( z.zonedDateTime.toInstant(), dialect ) + expected, + actual ); + expected = DateTimeUtils.adjustToDefaultPrecision( nowOffset.toInstant(), dialect ); + actual = DateTimeUtils.adjustToDefaultPrecision( z.offsetDateTime.toInstant(), dialect ); assertEquals( - DateTimeUtils.roundToDefaultPrecision( nowOffset.toInstant(), dialect ), - DateTimeUtils.roundToDefaultPrecision( z.offsetDateTime.toInstant(), dialect ) + expected, + actual ); assertEquals( systemZone, z.zonedDateTime.getZone() ); assertEquals( systemOffset, z.offsetDateTime.getOffset() ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/timezones/PassThruZonedTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/timezones/PassThruZonedTest.java index 8404eb25e4..45d28cecd1 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/timezones/PassThruZonedTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/timezones/PassThruZonedTest.java @@ -56,13 +56,17 @@ public class PassThruZonedTest { ZoneId systemZone = ZoneId.systemDefault(); ZoneOffset systemOffset = systemZone.getRules().getOffset( Instant.now() ); final Dialect dialect = scope.getSessionFactory().getJdbcServices().getDialect(); + Instant expected = DateTimeUtils.adjustToDefaultPrecision( nowZoned.toInstant(), dialect ); + Instant actual = DateTimeUtils.adjustToDefaultPrecision( z.zonedDateTime.toInstant(), dialect ); assertEquals( - DateTimeUtils.roundToDefaultPrecision( nowZoned.toInstant(), dialect ), - DateTimeUtils.roundToDefaultPrecision( z.zonedDateTime.toInstant(), dialect ) + expected, + actual ); + expected = DateTimeUtils.adjustToDefaultPrecision( nowOffset.toInstant(), dialect ); + actual = DateTimeUtils.adjustToDefaultPrecision( z.offsetDateTime.toInstant(), dialect ); assertEquals( - DateTimeUtils.roundToDefaultPrecision( nowOffset.toInstant(), dialect ), - DateTimeUtils.roundToDefaultPrecision( z.offsetDateTime.toInstant(), dialect ) + expected, + actual ); assertEquals( systemZone, z.zonedDateTime.getZone() ); assertEquals( systemOffset, z.offsetDateTime.getOffset() ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/timezones/UTCNormalizedInstantTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/timezones/UTCNormalizedInstantTest.java index dae2242aa8..9f4c569c43 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/timezones/UTCNormalizedInstantTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/timezones/UTCNormalizedInstantTest.java @@ -46,12 +46,12 @@ public class UTCNormalizedInstantTest { final Zoned z = s.find(Zoned.class, id); final Dialect dialect = scope.getSessionFactory().getJdbcServices().getDialect(); assertEquals( - DateTimeUtils.roundToDefaultPrecision( z.utcInstant, dialect ), - DateTimeUtils.roundToDefaultPrecision( instant, dialect ) + DateTimeUtils.adjustToDefaultPrecision( z.utcInstant, dialect ), + DateTimeUtils.adjustToDefaultPrecision( instant, dialect ) ); assertEquals( - DateTimeUtils.roundToDefaultPrecision( z.localInstant, dialect ), - DateTimeUtils.roundToDefaultPrecision( instant, dialect ) + DateTimeUtils.adjustToDefaultPrecision( z.localInstant, dialect ), + DateTimeUtils.adjustToDefaultPrecision( instant, dialect ) ); }); } @@ -79,13 +79,16 @@ public class UTCNormalizedInstantTest { scope.inSession( s-> { final Zoned z = s.find(Zoned.class, id); final Dialect dialect = scope.getSessionFactory().getJdbcServices().getDialect(); + Instant expected = DateTimeUtils.adjustToDefaultPrecision( z.utcInstant, dialect ); + Instant actual = DateTimeUtils.adjustToDefaultPrecision( instant, dialect ); assertEquals( - DateTimeUtils.roundToDefaultPrecision( z.utcInstant, dialect ), - DateTimeUtils.roundToDefaultPrecision( instant, dialect ) - ); - assertEquals( - DateTimeUtils.roundToDefaultPrecision( z.localInstant, dialect ), - DateTimeUtils.roundToDefaultPrecision( instant, dialect ) + expected, + actual + ); + expected = DateTimeUtils.adjustToDefaultPrecision( z.localInstant, dialect ); + assertEquals( + expected, + actual ); }); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/timezones/UTCNormalizedZonedTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/timezones/UTCNormalizedZonedTest.java index cbab481e0f..88dd037d9d 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/timezones/UTCNormalizedZonedTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/timezones/UTCNormalizedZonedTest.java @@ -1,5 +1,6 @@ package org.hibernate.orm.test.timezones; +import java.time.Instant; import java.time.OffsetDateTime; import java.time.ZoneId; import java.time.ZoneOffset; @@ -53,13 +54,17 @@ public class UTCNormalizedZonedTest { scope.inSession( s-> { Zoned z = s.find(Zoned.class, id); final Dialect dialect = scope.getSessionFactory().getJdbcServices().getDialect(); + Instant expected = DateTimeUtils.adjustToDefaultPrecision( nowZoned.toInstant(), dialect ); + Instant actual = DateTimeUtils.adjustToDefaultPrecision( z.zonedDateTime.toInstant(), dialect ); assertEquals( - DateTimeUtils.roundToDefaultPrecision( nowZoned.toInstant(), dialect ), - DateTimeUtils.roundToDefaultPrecision( z.zonedDateTime.toInstant(), dialect ) + expected, + actual ); + expected = DateTimeUtils.adjustToDefaultPrecision( nowOffset.toInstant(), dialect ); + actual = DateTimeUtils.adjustToDefaultPrecision( z.offsetDateTime.toInstant(), dialect ); assertEquals( - DateTimeUtils.roundToDefaultPrecision( nowOffset.toInstant(), dialect ), - DateTimeUtils.roundToDefaultPrecision( z.offsetDateTime.toInstant(), dialect ) + expected, + actual ); assertEquals( ZoneId.of("Z"), z.zonedDateTime.getZone() ); assertEquals( ZoneOffset.ofHours(0), z.offsetDateTime.getOffset() );