mirror of https://github.com/apache/kafka.git
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 <aschofield@confluent.io> --------- Signed-off-by: Alex <wenhsuan.alexyu@gmail.com>
This commit is contained in:
parent
8628d74c49
commit
3fcc0c2877
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue