From 3fcc0c287795c6a591216617e0d5a02bd6fdbfc3 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 16 Sep 2025 01:26:47 +0800 Subject: [PATCH] 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](https://github.com/apache/kafka/pull/18611#discussion_r2318146619) Reviewers: Andrew Schofield --------- Signed-off-by: Alex --- .../test/java/org/apache/kafka/connect/data/ValuesTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/connect/api/src/test/java/org/apache/kafka/connect/data/ValuesTest.java b/connect/api/src/test/java/org/apache/kafka/connect/data/ValuesTest.java index 6be0b4a3772..d100be29b4d 100644 --- a/connect/api/src/test/java/org/apache/kafka/connect/data/ValuesTest.java +++ b/connect/api/src/test/java/org/apache/kafka/connect/data/ValuesTest.java @@ -30,7 +30,6 @@ import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; import java.time.Instant; -import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.ZoneId; @@ -903,7 +902,7 @@ public class ValuesTest { // ISO8601 strings - accept a string matching pattern "yyyy-MM-dd" LocalDateTime localTimeTruncated = localTime.truncatedTo(ChronoUnit.DAYS); - java.util.Date d3 = Values.convertToDate(Date.SCHEMA, LocalDate.ofEpochDay(days).format(DateTimeFormatter.ISO_LOCAL_DATE)); + java.util.Date d3 = Values.convertToDate(Date.SCHEMA, localTime.format(DateTimeFormatter.ISO_LOCAL_DATE)); LocalDateTime date3 = LocalDateTime.ofInstant(Instant.ofEpochMilli(d3.getTime()), ZoneId.systemDefault()); assertEquals(localTimeTruncated, date3);