diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/internal/revisioninfo/RevisionTimestampValueResolver.java b/hibernate-envers/src/main/java/org/hibernate/envers/internal/revisioninfo/RevisionTimestampValueResolver.java index 6e82486271..c838948081 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/internal/revisioninfo/RevisionTimestampValueResolver.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/internal/revisioninfo/RevisionTimestampValueResolver.java @@ -69,7 +69,7 @@ public class RevisionTimestampValueResolver { return localDateTime; } else { - return localDateTime.atZone( ZoneId.systemDefault() ).toInstant().getEpochSecond(); + return localDateTime.atZone( ZoneId.systemDefault() ).toInstant().toEpochMilli(); } } return null; diff --git a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/reventity/Custom.java b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/reventity/Custom.java index dbe3b20853..81836bfbbe 100644 --- a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/reventity/Custom.java +++ b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/reventity/Custom.java @@ -6,6 +6,8 @@ */ package org.hibernate.orm.test.envers.integration.reventity; +import java.time.LocalDateTime; +import java.time.ZoneId; import java.util.Arrays; import java.util.Date; import java.util.HashSet; @@ -71,8 +73,16 @@ public class Custom extends BaseEnversJPAFunctionalTestCase { @Test public void testTimestamps() { - assert getAuditReader().getRevisionNumberForDate( new Date( timestamp2 ) ).intValue() == 1; - assert getAuditReader().getRevisionNumberForDate( new Date( timestamp3 ) ).intValue() == 2; + final Date date1 = new Date( timestamp2 ); + final Date date2 = new Date( timestamp3 ); + + assert getAuditReader().getRevisionNumberForDate( date1 ).intValue() == 1; + assert getAuditReader().getRevisionNumberForDate( date2 ).intValue() == 2; + + final LocalDateTime localDateTime1 = LocalDateTime.ofInstant( date1.toInstant(), ZoneId.systemDefault() ); + final LocalDateTime localDateTime2 = LocalDateTime.ofInstant( date2.toInstant(), ZoneId.systemDefault() ); + assert getAuditReader().getRevisionNumberForDate( localDateTime1 ).intValue() == 1; + assert getAuditReader().getRevisionNumberForDate( localDateTime2 ).intValue() == 2; } @Test