Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import java.math.BigDecimal;
import java.time.*;
import java.util.concurrent.ThreadLocalRandom;
import java.util.function.Consumer;

@RunWith(VertxUnitRunner.class)
Expand Down Expand Up @@ -148,7 +149,17 @@ public void testEncodeDateTime(TestContext ctx) {
@Test
@Repeat(100)
public void testEncodeOffsetDateTime(TestContext ctx) {
OffsetDateTime now = LocalDateTime.now().atOffset(ZoneOffset.ofHoursMinutes(-3, -15));
/*
Starting from Java 11, LocalDateTime.now() can have microseconds precision.
But the test database defines the test_datetimeoffset column with scale of 5.

Therefore, in order to get consistent behavior between Java 8 and Java 11,
we erase the nanoOfSecond value obtained from the clock with a random number
which has at most tens of microseconds precision.
*/
int nanoOfSecond = ThreadLocalRandom.current().nextInt(100_000) * 10_000;
OffsetDateTime now = LocalDateTime.now().withNano(nanoOfSecond)
.atOffset(ZoneOffset.ofHoursMinutes(-3, -15));
testPreparedQueryEncodeGeneric(ctx, "not_nullable_datatype", "test_datetimeoffset", now, row -> {
ColumnChecker.checkColumn(0, "test_datetimeoffset")
.returns(Tuple::getValue, Row::getValue, now)
Expand Down