You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "AbhishekPathania (via GitHub)" <gi...@apache.org> on 2026/09/11 08:41:08 UTC

[PR] GH-1293: Use floor division when splitting epoch millis into day and time [arrow-java]

AbhishekPathania opened a new pull request, #1294:
URL: https://github.com/apache/arrow-java/pull/1294

   ## What's Changed
   
   `DateTimeUtils.getTimestampValue` split epoch millis into an epoch day and a time-of-day remainder using `/` and `%`, which truncate toward zero. Only the remainder half compensated for negative input (`LocalTime.ofNanoOfDay` rejects negatives), while the epoch-day half did not. For any negative value that is not an exact multiple of a day the two halves therefore described different days, and the returned timestamp was one day later than the instant it was given.
   
   Worked example: `-618102000000` is 1950-06-01 01:00:00 UTC. `-618102000000 / 86400000` truncates to `-7153`, i.e. 1950-06-02, while the remainder is the 01:00:00 of 1950-06-01, so the method returned `1950-06-02 01:00:00`.
   
   This is reachable through `ArrowFlightJdbcDateVectorAccessor.getDate(Calendar)`: a date vector value is day-aligned on its own, but `DateTimeUtils.applyCalendarOffset` shifts it off that alignment whenever the supplied `Calendar` uses a zone other than the JVM default, so every pre-1970 date came back a day late.
   
   The fix uses `Math.floorDiv` and `Math.floorMod` for both halves, which keeps the day and the remainder on the same day and makes the manual negative adjustment redundant. Positive input is unaffected, since both functions agree with `/` and `%` there.
   
   The existing negative-input test used an exact midnight value, where truncating and flooring division agree, so it could not catch this. `DateTimeUtilsTest` gains a case one hour past midnight on the same pre-epoch day, which fails before this change and passes after it.
   
   Closes #1293.
   


-- 
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: github-unsubscribe@arrow.apache.org

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


Re: [PR] GH-1293: Use floor division when splitting epoch millis into day and time [arrow-java]

Posted by "lidavidm (via GitHub)" <gi...@apache.org>.
lidavidm commented on PR #1294:
URL: https://github.com/apache/arrow-java/pull/1294#issuecomment-5693198432

   Hmm, RC CI is failing, but I think that's not related to this.


-- 
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: github-unsubscribe@arrow.apache.org

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


Re: [PR] GH-1293: Use floor division when splitting epoch millis into day and time [arrow-java]

Posted by "lidavidm (via GitHub)" <gi...@apache.org>.
lidavidm merged PR #1294:
URL: https://github.com/apache/arrow-java/pull/1294


-- 
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: github-unsubscribe@arrow.apache.org

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


Re: [PR] GH-1293: Use floor division when splitting epoch millis into day and time [arrow-java]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #1294:
URL: https://github.com/apache/arrow-java/pull/1294#issuecomment-5631786469

   
   <!-- label_helper_comment -->
   Thank you for opening a pull request!
   
   Please label the PR with one or more of:
   
   - bug-fix
   - chore
   - dependencies
   - documentation
   - enhancement
   
   Also, add the 'breaking-change' label if appropriate.
   
   See [CONTRIBUTING.md](https://github.com/apache/arrow-java/blob/main/CONTRIBUTING.md) for details.
   


-- 
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: github-unsubscribe@arrow.apache.org

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


Re: [PR] GH-1293: Use floor division when splitting epoch millis into day and time [arrow-java]

Posted by "AbhishekPathania (via GitHub)" <gi...@apache.org>.
AbhishekPathania commented on PR #1294:
URL: https://github.com/apache/arrow-java/pull/1294#issuecomment-5631876431

   The "Ensure PR format" check is failing only on the missing label step. I tried to add `bug-fix` when opening the PR, but label changes need write access on the repo (403 for an outside contributor). Could a committer add `bug-fix`? The title and the issue link both pass.


-- 
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: github-unsubscribe@arrow.apache.org

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