Integrated: 8314604: j.text.DecimalFormat behavior regarding patterns is not clear
Justin Lu
jlu at openjdk.org
Wed Sep 6 18:05:52 UTC 2023
On Fri, 18 Aug 2023 21:28:34 GMT, Justin Lu <jlu at openjdk.org> wrote:
> Please review this PR and [CSR](https://bugs.openjdk.org/browse/JDK-8314607) which clarifies the behavior of patterns in regards to the max integer digits in j.text.DecimalFormat.
>
> The current specification (of `applyPattern`) states that patterns do not set the value of max integer digits. This is incorrect, these methods/constructors do set a value for the max integer digits. If the pattern is in scientific notation, the max integer digits value is derived from the pattern. Otherwise, the pattern is ignored, and the limit is set to `Integer.MAX_VALUE`.
>
> See below,
>
> DecimalFormat df = new DecimalFormat();
> df.applyPattern("000.000E0");
> df.getMaximumIntegerDigits(); // ==> 3
> df.applyPattern("000.000");
> df.getMaximumIntegerDigits(); // ==> 2147483647
>
> DecimalFormat df = new DecimalFormat("000.000");
> df.getMaximumIntegerDigits(); // ==> 2147483647
> DecimalFormat df = new DecimalFormat("000.000E0");
> df.getMaximumIntegerDigits(); // ==> 3
>
>
> Method descriptions should be fixed, and the relevant constructors need to mention the behavior as well.
This pull request has now been integrated.
Changeset: 86a18f5e
Author: Justin Lu <jlu at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/86a18f5e2e0825dddb77656b2f43f64684f1464c
Stats: 22 lines in 1 file changed: 13 ins; 2 del; 7 mod
8314604: j.text.DecimalFormat behavior regarding patterns is not clear
Reviewed-by: naoto
-------------
PR: https://git.openjdk.org/jdk/pull/15349
More information about the core-libs-dev
mailing list