Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6503196

API doc for DecimalFormat::getMaximumIntegerDigits is unclear

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 23
    • 6u1
    • core-libs
    • None
    • b07
    • generic
    • generic

      The method java.text.DecimalFormat.getMaximumIntegerDigits() returns INTEGER.MAX_VALUE while the spec states that return value should be at last 309:
      ======
          Gets the maximum number of digits allowed in the integer portion of a number. For formatting numbers other than BigInteger and BigDecimal objects, the lower of the return value and 309 is used.
      ======

      You may reproduce it using following program:

      import java.text.DecimalFormat;

      public class T {
          public static void main(String[] args) {
              DecimalFormat df = new DecimalFormat();

              String patterns[] = {"000.00", "###0.###", "##,###.0", "000,000.000", "prefix#suffix", "prefix", "#0,00000.00;00.0" };
              for (int i = 0; i < patterns.length; i++) {
                  df.applyPattern(patterns[i]);
                  System.out.println("applyPattern(String pattern) fails with pattern \"" + patterns[i] + "\"");
                  System.out.println(" getMaximumIntegerDigits() returns " + df.getMaximumIntegerDigits());
              }
          }
      }

            jlu Justin Lu
            ydanilev Yury Danilevich (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: