FULL PRODUCT VERSION :
java version "1.5.0_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Using the DecimalFormat(String) constructor:
If the pattern contains a negative sub-pattern that does not exactly reproduce the positive sub pattern (with prefix/suffix) the suffix of the negative patten is lost.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the program that's given below.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expected the close paren to appear as the negative suffix for every pattern.
ACTUAL -
in pat #0.0#;(0) out pat #0.0#;(#0.0# neg prefix ( neg suffix -1.1 (1.1
in pat #0.0;(#) out pat #0.0;(#0.0 neg prefix ( neg suffix -1.1 (1.1
in pat #0.0#;(#) out pat #0.0#;(#0.0# neg prefix ( neg suffix -1.1 (1.1
in pat #0.0#;(#0.0#) out pat #0.0#;(#0.0#) neg prefix ( neg suffix ) -1.1 (1.1)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.text.DecimalFormat;
import java.text.NumberFormat;
class DecimalFormatPlay {
public static void main (String[] args) {
String[] pats = {
"#0.0#;(0)", "#0.0;(#)", "#0.0#;(#)",
"#0.0#;(#0.0#)"
};
for (int i = 0; i < pats.length; i++) {
String s = pats[i];
DecimalFormat df = new DecimalFormat(s);
System.out.println("in pat " + s +
" out pat " + df.toPattern() +
" neg prefix " + df.getNegativePrefix() +
" neg suffix " + df.getNegativeSuffix() +
" -1.1 " + df.format(-1.1));
}
}
}
---------- END SOURCE ----------
java version "1.5.0_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Using the DecimalFormat(String) constructor:
If the pattern contains a negative sub-pattern that does not exactly reproduce the positive sub pattern (with prefix/suffix) the suffix of the negative patten is lost.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the program that's given below.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expected the close paren to appear as the negative suffix for every pattern.
ACTUAL -
in pat #0.0#;(0) out pat #0.0#;(#0.0# neg prefix ( neg suffix -1.1 (1.1
in pat #0.0;(#) out pat #0.0;(#0.0 neg prefix ( neg suffix -1.1 (1.1
in pat #0.0#;(#) out pat #0.0#;(#0.0# neg prefix ( neg suffix -1.1 (1.1
in pat #0.0#;(#0.0#) out pat #0.0#;(#0.0#) neg prefix ( neg suffix ) -1.1 (1.1)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.text.DecimalFormat;
import java.text.NumberFormat;
class DecimalFormatPlay {
public static void main (String[] args) {
String[] pats = {
"#0.0#;(0)", "#0.0;(#)", "#0.0#;(#)",
"#0.0#;(#0.0#)"
};
for (int i = 0; i < pats.length; i++) {
String s = pats[i];
DecimalFormat df = new DecimalFormat(s);
System.out.println("in pat " + s +
" out pat " + df.toPattern() +
" neg prefix " + df.getNegativePrefix() +
" neg suffix " + df.getNegativeSuffix() +
" -1.1 " + df.format(-1.1));
}
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-6594713 [Fmt-De] DecimalFormat incorrectly formats values if the negative subpattern is (#)
-
- Closed
-