8314604: j.text.DecimalFormat behavior regarding patterns is not clear

Reviewed-by: naoto
This commit is contained in:
Justin Lu 2023-09-06 18:02:39 +00:00
parent bd477810b1
commit 86a18f5e2e

View File

@ -84,9 +84,18 @@ import sun.util.locale.provider.ResourceBundleBasedAdapter;
* the {@code NumberFormat} factory methods, the pattern and symbols are
* read from localized {@code ResourceBundle}s.
*
* <h2>Patterns</h2>
* <h2 id="patterns">Patterns</h2>
*
* {@code DecimalFormat} patterns have the following syntax:
* Note: For any given {@code DecimalFormat} pattern, if the pattern is not
* in scientific notation, the maximum number of integer digits will not be
* derived from the pattern, and instead set to {@link Integer#MAX_VALUE}.
* Otherwise, if the pattern is in scientific notation, the maximum number of
* integer digits will be derived from the pattern. This derivation is detailed
* in the {@link ##scientific_notation Scientific Notation} section. This behavior
* is the typical end-user desire; {@link #setMaximumIntegerDigits(int)} can be
* used to manually adjust the maximum integer digits.
*
* <p> {@code DecimalFormat} patterns have the following syntax:
* <blockquote><pre>
* <i>Pattern:</i>
* <i>PositivePattern</i>
@ -245,7 +254,7 @@ import sun.util.locale.provider.ResourceBundleBasedAdapter;
* </table>
* </blockquote>
*
* <h3>Scientific Notation</h3>
* <h3 id="scientific_notation">Scientific Notation</h3>
*
* <p>Numbers in scientific notation are expressed as the product of a mantissa
* and a power of ten, for example, 1234 can be expressed as 1.234 x 10^3. The
@ -449,6 +458,8 @@ public class DecimalFormat extends NumberFormat {
* for the default {@link java.util.Locale.Category#FORMAT FORMAT} locale.
* This is a convenient way to obtain a
* DecimalFormat when internationalization is not the main concern.
* The number of maximum integer digits is usually not derived from the pattern.
* See the note in the {@link ##patterns Patterns} section for more detail.
* <p>
* To obtain standard formats for a given locale, use the factory methods
* on NumberFormat such as getNumberInstance. These factories will
@ -474,6 +485,8 @@ public class DecimalFormat extends NumberFormat {
* Creates a DecimalFormat using the given pattern and symbols.
* Use this constructor when you need to completely customize the
* behavior of the format.
* The number of maximum integer digits is usually not derived from the pattern.
* See the note in the {@link ##patterns Patterns} section for more detail.
* <p>
* To obtain standard formats for a given
* locale, use the factory methods on NumberFormat such as
@ -3298,9 +3311,8 @@ public class DecimalFormat extends NumberFormat {
* These properties can also be changed individually through the
* various setter methods.
* <p>
* There is no limit to integer digits set
* by this routine, since that is the typical end-user desire;
* use setMaximumInteger if you want to set a real value.
* The number of maximum integer digits is usually not derived from the pattern.
* See the note in the {@link ##patterns Patterns} section for more detail.
* For negative numbers, use a second pattern, separated by a semicolon
* <P>Example {@code "#,#00.0#"} &rarr; 1,234.56
* <P>This means a minimum of 2 integer digits, 1 fraction digit, and
@ -3325,9 +3337,8 @@ public class DecimalFormat extends NumberFormat {
* These properties can also be changed individually through the
* various setter methods.
* <p>
* There is no limit to integer digits set
* by this routine, since that is the typical end-user desire;
* use setMaximumInteger if you want to set a real value.
* The number of maximum integer digits is usually not derived from the pattern.
* See the note in the {@link ##patterns Patterns} section for more detail.
* For negative numbers, use a second pattern, separated by a semicolon
* <P>Example {@code "#,#00.0#"} &rarr; 1,234.56
* <P>This means a minimum of 2 integer digits, 1 fraction digit, and