JDK-4147295 : java.text.DecimalFormat.applyPattern doesn't set minimum integer digits
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.text
  • Affected Version: 1.2.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.5
  • CPU: sparc
  • Submitted: 1998-06-10
  • Updated: 1998-07-07
  • Resolved: 1998-07-07
Related Reports
Duplicate :  
Relates :  
Description

Name: dfC67450			Date: 06/10/98



The java.text.DecimalFormat.applyPattern(String pattern) doesn't set minimum
integer digits correctly. For example, when applying "#,###" pattern minimum
integer digits should be equal to 0, but getMinimumIntegerDigits() returns 1.

Here is the test demonstrating the bug:

-----------------TestD.java------------------------
import java.text.*;

public class TestD {
    public static void main (String args[]){
        DecimalFormat sdf = new DecimalFormat();
        String pattern = "#,###";
        System.out.println("Applying pattern \"" + pattern + "\"");
        sdf.applyPattern(pattern);
        int minIntDig = sdf.getMinimumIntegerDigits();
        if (minIntDig != 0) {
          System.out.println("Test failed");
          System.out.println("  Minimum integer digits : " + minIntDig);
          System.out.println("  new pattern: " + sdf.toPattern());
        } else {
          System.out.println("Test passed");
          System.out.println("  Minimum integer digits : " + minIntDig);
        }
    }
}
---------Output from the test---------------------
Applying pattern "#,###"
Test failed
  Minimum integer digits : 1
  new pattern: #,##0
--------------------------------------------------

======================================================================

Comments
EVALUATION This is another duplicate of: 4139344 4134300 (the "root" bug) alan.liu@eng 1998-07-07
07-07-1998