This is an automated email from the ASF dual-hosted git repository.

lianetm pushed a commit to branch 4.1
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/4.1 by this push:
     new 43cb8c3bd25 MINOR: Fix an off-by-one issue in ValuesTest (#20520)
43cb8c3bd25 is described below

commit 43cb8c3bd25a1fbc2afc33e777780dbe4aad36a9
Author: Alex <[email protected]>
AuthorDate: Tue Sep 16 01:26:47 2025 +0800

    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 <[email protected]>
    
    ---------
    
    Signed-off-by: Alex <[email protected]>
---
 .../api/src/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 ac6eef6fa68..5ca0f93d076 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;
@@ -904,7 +903,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);
 

Reply via email to