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
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
- duplicates
-
JDK-4503190 [Fmt-Nu] Method java.text.DecimalFormat.applyPattern(String pattern) works incorrectly.
-
- Closed
-
- relates to
-
JDK-4503190 [Fmt-Nu] Method java.text.DecimalFormat.applyPattern(String pattern) works incorrectly.
-
- Closed
-