HHH-17080 Fix LocalDateTime resolved value precision
This commit is contained in:
parent
7d197329d6
commit
e1f9ccaee9
|
@ -69,7 +69,7 @@ public class RevisionTimestampValueResolver {
|
||||||
return localDateTime;
|
return localDateTime;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return localDateTime.atZone( ZoneId.systemDefault() ).toInstant().getEpochSecond();
|
return localDateTime.atZone( ZoneId.systemDefault() ).toInstant().toEpochMilli();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.orm.test.envers.integration.reventity;
|
package org.hibernate.orm.test.envers.integration.reventity;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -71,8 +73,16 @@ public class Custom extends BaseEnversJPAFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTimestamps() {
|
public void testTimestamps() {
|
||||||
assert getAuditReader().getRevisionNumberForDate( new Date( timestamp2 ) ).intValue() == 1;
|
final Date date1 = new Date( timestamp2 );
|
||||||
assert getAuditReader().getRevisionNumberForDate( new Date( timestamp3 ) ).intValue() == 2;
|
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
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue