m1a2st commented on code in PR #18611:
URL: https://github.com/apache/kafka/pull/18611#discussion_r1923514351


##########
connect/api/src/test/java/org/apache/kafka/connect/data/ValuesTest.java:
##########
@@ -901,8 +902,12 @@ public void shouldConvertDateValues() {
         assertEquals(currentDate, d2);
 
         // ISO8601 strings - accept a string matching pattern "yyyy-MM-dd"
+        // Values.convertToDate convert the "yyyy-MM-dd" string will miss the 
time and timezone information, 
+        // so we need to adjust the date from the current timezone to UTC0
+        TimeZone tz = TimeZone.getDefault();
+        java.util.Date currentDate3 = new java.util.Date(current.getTime() - 
currentMillis - tz.getOffset(current.getTime()));
         java.util.Date d3 = Values.convertToDate(Date.SCHEMA, 
LocalDate.ofEpochDay(days).format(DateTimeFormatter.ISO_LOCAL_DATE));
-        assertEquals(currentDate, d3);

Review Comment:
   We can observe that when `java.util.Date` performs equals comparison, it 
takes timezone into account. Therefore, the equals comparison will yield 
different results under different timezones. In my case, being in UTC+8, it 
results in an 8-hour difference.
   
   
https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/util/Date.java#L1210



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to