Skip to content

Commit 3fcc0c2

Browse files
authored
MINOR: Fix an off-by-one issue in ValuesTest (#20520)
This test case ensures that the parser can convert ISO8601 correctly. However, when the local time falls on a different day than the UTC time, there will be an off-by-one issue. I changed the test to convert the local time and then compare it with the expected local time. This should fix the off-by-one issue. [Reference link](#18611 (comment)) Reviewers: Andrew Schofield <[email protected]> --------- Signed-off-by: Alex <[email protected]>
1 parent 8628d74 commit 3fcc0c2

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

connect/api/src/test/java/org/apache/kafka/connect/data/ValuesTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import java.nio.charset.StandardCharsets;
3131
import java.text.SimpleDateFormat;
3232
import java.time.Instant;
33-
import java.time.LocalDate;
3433
import java.time.LocalDateTime;
3534
import java.time.LocalTime;
3635
import java.time.ZoneId;
@@ -903,7 +902,7 @@ public void shouldConvertDateValues() {
903902

904903
// ISO8601 strings - accept a string matching pattern "yyyy-MM-dd"
905904
LocalDateTime localTimeTruncated = localTime.truncatedTo(ChronoUnit.DAYS);
906-
java.util.Date d3 = Values.convertToDate(Date.SCHEMA, LocalDate.ofEpochDay(days).format(DateTimeFormatter.ISO_LOCAL_DATE));
905+
java.util.Date d3 = Values.convertToDate(Date.SCHEMA, localTime.format(DateTimeFormatter.ISO_LOCAL_DATE));
907906
LocalDateTime date3 = LocalDateTime.ofInstant(Instant.ofEpochMilli(d3.getTime()), ZoneId.systemDefault());
908907
assertEquals(localTimeTruncated, date3);
909908

0 commit comments

Comments
 (0)