On Fri, 26 Jul 2024 15:32:18 GMT, Shaojin Wen <d...@openjdk.org> wrote:

>> src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java 
>> line 3818:
>> 
>>> 3816:             }
>>> 3817:             // add fraction
>>> 3818:             if (fractionalDigits > 0) {
>> 
>> This breaks the logic. `fractionalDigits` can be negative in the block below
>
> If fractionalDigits < 0, printNano is implemented in LocalDateTime

`fractionalDigits == -2` is used to output 0, 3, 6 or 9 fractional digits as 
needed. This can be handled by `LocalDateTime`.

`fractionalDigits == -1`  is used to output as many fractional digits as 
needed, from 0 to 9 digits. This is NOT handled by `LocalDateTime`.

Furthermore, if the `-2` branch is handled by `LocalDateTime` then the logic 
below for `-2` is redundant.

If the tests did not fail as a result of this change, then I imagine the tests 
need improving.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/20353#discussion_r1694248869

Reply via email to