Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
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;
Expand Down Expand Up @@ -903,7 +902,7 @@ public void shouldConvertDateValues() {

// 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));
Copy link
Preview

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable days is referenced in the original code but not visible in this diff. If days was calculated from localTime, this change may not fix the off-by-one issue as intended, since localTime.format(DateTimeFormatter.ISO_LOCAL_DATE) will still use the same local date that could differ from UTC. Consider using a fixed date string or ensuring the test uses UTC time consistently.

Copilot uses AI. Check for mistakes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change may not fix the off-by-one issue as intended, since localTime.format(DateTimeFormatter.ISO_LOCAL_DATE) will still use the same local date that could differ from UTC.

@WenHsuanYu What do you think for this comment?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my testing, I believe I saw equality (which is what the test was checking for), but not necessarily the "correct" date. If this is still not satisfactory, I suggest removing this third test variant in this test case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndrewJSchofield Thanks for your explanation. Getting hung up on the "correct" time is kind of overkill. This version is good to me 💯

LocalDateTime date3 = LocalDateTime.ofInstant(Instant.ofEpochMilli(d3.getTime()), ZoneId.systemDefault());
assertEquals(localTimeTruncated, date3);

Expand Down