On Fri, 5 May 2023 21:28:25 GMT, Roger Riggs <rri...@openjdk.org> wrote:
> The implementation of java.time.Instant.until(I2, ChronoUnit) in some cases > did not correctly borrow or carry from the nanos to the seconds when > computing using ChronoUnit.MILLIS or ChronoUnit.MICROS. > The errant computation was introduced by > [JDK-8273369](https://bugs.openjdk.org/browse/JDK-8273369). src/java.base/share/classes/java/time/Instant.java line 1173: > 1171: private long microsUntil(Instant end) { > 1172: long microsDiff = Math.multiplyExact(end.seconds - seconds, > MICROS_PER_SECOND); > 1173: long nanosDiff = end.nanos - nanos; FWIW, `nanosDiff` could be declared `int` to slightly speed up the division later in the code, while still not risking overflows. Similarly in `millisUntil()`. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/13846#discussion_r1186747228