JDK-6353978 : [Fmt-Nu] DecimalFormat.applyPattern() allows suffix with special characters
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.text
  • Affected Version: 6
  • Priority: P4
  • Status: Resolved
  • Resolution: Duplicate
  • OS: solaris_9
  • CPU: sparc
  • Submitted: 2005-11-22
  • Updated: 2017-05-31
  • Resolved: 2017-05-31
Related Reports
Duplicate :  
Relates :  
Description
The specification of DecimalFormat states:

 Prefix:
         any Unicode characters except \uFFFE, \uFFFF, and special characters
 Suffix:
         any Unicode characters except \uFFFE, \uFFFF, and special characters

However, the implementation allows suffix with special characters like "#".

For example:

import java.text.*;

public class DecimalFormatTest01 {

    public static void main (String[] args) {
        String pattern1 = "###,000.000suffix2##";
        DecimalFormat df = new DecimalFormat();
        try {
            df.applyPattern(pattern1);
            System.out.println("FAILED: IllegalArgumentException expected for pattern " + pattern1);
            System.out.println("Suffix: " + df.getPositiveSuffix());
        } catch (IllegalArgumentException iae) {
            // OKAY
        }
    }
}

Output in JDK 6.0:

FAILED: IllegalArgumentException expected for pattern ###,000.000suffix2##
Suffix: suffix2

Comments
Duplicate of 4503190
31-05-2017

EVALUATION It should throw an exception. Will be fixed in Dolphin.
07-12-2005