-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
1.2.0
-
generic
-
solaris_2.6
It appears that if a DecimalFormat pattern contains both a positive
and negative subpattern, then the positive subpattern's fraction part is
being used for negative numbers. Or something similar.
Value -1.0 formatted with "#0.0000#;-#0.0#" results in "-1.0000".
Should have been "-1.0".
Simple test program:
--------------------
import java.text.DecimalFormat;
public class DecimalFormatTest {
private static void show(double d, String s) {
String result = new DecimalFormat(s).format(d);
System.out.println("Value " + d +
" Format " + s +
" Result '" + result + "'");
}
public static void main(String[] args) {
show(-1.0, "#0.0000#;-#0.0#");
}
}
-----------------------
(423)# javac DecimalFormatTest.java
(424)# java DecimalFormatTest
Value -1.0 Format #0.0000#;-#0.0# Result '-1.0000'
(425)# java -fullversion
java full version "JDK-1.2fcs-B"
(426)#