On Wed, 3 Nov 2021 12:44:39 GMT, Claes Redestad <redes...@openjdk.org> wrote:

>> I'll see to it.
>
> When adding a test for this I discovered that  
> `FractionPrinterParser::format` will end up calling 
> `field.range().checkValidValue(value, field)` 
> [here](https://github.com/openjdk/jdk/blob/579b2c017f24f2266abefd35c2b8f28fa7268d93/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java#L3543).
>  This means that the pre-existing implementation does check the value range 
> and throws exceptions when trying to print a `value` outside of the `field` 
> range. 
> 
> To mimic the existing behavior we have to do the same check in 
> `NanosPrinterParser::format` and drop the fallback (which would have somewhat 
> nonsensical output for values outside the range, anyhow).

Added a test case showing that values that are outside the range throw 
`DateTimeException`. This passes with and without the patch and mainly 
documents the pre-existing behavior.

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

PR: https://git.openjdk.java.net/jdk/pull/6188

Reply via email to