FULL PRODUCT VERSION :
java version "1.7.0_25"
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
Hello,
The following test case does not produce the same output twice contrarily to what the DecimalFormat javadoc says:
import java.text.DecimalFormat;
public class Test {
public static void main(String[] args) throws Exception {
String pattern1 = "#,##0.0#;(#)";
String pattern2 = "#,##0.0#;(#,##0.0#)";
DecimalFormat format1 = new DecimalFormat(pattern1);
System.out.println(pattern1 + " -> " + format1.format(-1000));
DecimalFormat format2 = new DecimalFormat(pattern2);
System.out.println(pattern2 + " -> " + format2.format(-1000));
}
}
Ouput is:
#,##0.0#;(#) -> (1,000.0
#,##0.0#;(#,##0.0#) -> (1,000.0)
Notice the missing closing parenthesis.
Best regards,
Thomas Leplus
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the following piece of code:
import java.text.DecimalFormat;
public class Test {
public static void main(String[] args) throws Exception {
String pattern1 = "#,##0.0#;(#)";
String pattern2 = "#,##0.0#;(#,##0.0#)";
DecimalFormat format1 = new DecimalFormat(pattern1);
System.out.println(pattern1 + " -> " + format1.format(-1000));
DecimalFormat format2 = new DecimalFormat(pattern2);
System.out.println(pattern2 + " -> " + format2.format(-1000));
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
#,##0.0#;(#) -> (1,000.0)
#,##0.0#;(#,##0.0#) -> (1,000.0)
ACTUAL -
#,##0.0#;(#) -> (1,000.0
#,##0.0#;(#,##0.0#) -> (1,000.0)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.text.DecimalFormat;
public class Test {
public static void main(String[] args) throws Exception {
String pattern1 = "#,##0.0#;(#)";
String pattern2 = "#,##0.0#;(#,##0.0#)";
DecimalFormat format1 = new DecimalFormat(pattern1);
System.out.println(pattern1 + " -> " + format1.format(-1000));
DecimalFormat format2 = new DecimalFormat(pattern2);
System.out.println(pattern2 + " -> " + format2.format(-1000));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use the full pattern instead of (#).
java version "1.7.0_25"
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
Hello,
The following test case does not produce the same output twice contrarily to what the DecimalFormat javadoc says:
import java.text.DecimalFormat;
public class Test {
public static void main(String[] args) throws Exception {
String pattern1 = "#,##0.0#;(#)";
String pattern2 = "#,##0.0#;(#,##0.0#)";
DecimalFormat format1 = new DecimalFormat(pattern1);
System.out.println(pattern1 + " -> " + format1.format(-1000));
DecimalFormat format2 = new DecimalFormat(pattern2);
System.out.println(pattern2 + " -> " + format2.format(-1000));
}
}
Ouput is:
#,##0.0#;(#) -> (1,000.0
#,##0.0#;(#,##0.0#) -> (1,000.0)
Notice the missing closing parenthesis.
Best regards,
Thomas Leplus
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the following piece of code:
import java.text.DecimalFormat;
public class Test {
public static void main(String[] args) throws Exception {
String pattern1 = "#,##0.0#;(#)";
String pattern2 = "#,##0.0#;(#,##0.0#)";
DecimalFormat format1 = new DecimalFormat(pattern1);
System.out.println(pattern1 + " -> " + format1.format(-1000));
DecimalFormat format2 = new DecimalFormat(pattern2);
System.out.println(pattern2 + " -> " + format2.format(-1000));
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
#,##0.0#;(#) -> (1,000.0)
#,##0.0#;(#,##0.0#) -> (1,000.0)
ACTUAL -
#,##0.0#;(#) -> (1,000.0
#,##0.0#;(#,##0.0#) -> (1,000.0)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.text.DecimalFormat;
public class Test {
public static void main(String[] args) throws Exception {
String pattern1 = "#,##0.0#;(#)";
String pattern2 = "#,##0.0#;(#,##0.0#)";
DecimalFormat format1 = new DecimalFormat(pattern1);
System.out.println(pattern1 + " -> " + format1.format(-1000));
DecimalFormat format2 = new DecimalFormat(pattern2);
System.out.println(pattern2 + " -> " + format2.format(-1000));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use the full pattern instead of (#).
- duplicates
-
JDK-8072449 Javadoc of java.text.DecimalFormat is wrong
- Closed
-
JDK-6609740 [Fmt-De] format error in DecimalFormat
- Resolved