A DESCRIPTION OF THE PROBLEM :
/**
* The {@link DecimalFormat} Javadoc says: <blockquote>That means that
* <code>"#,##0.0#;(#)"</code> produces precisely the same behavior as
* <code>"#,##0.0#;(#,##0.0#)"</code> .</blockquote>
*/
@Test
public void verifyDecimalFormatJavadoc() {
DecimalFormat format1 = new DecimalFormat("#,##0.0#;(#)");
DecimalFormat format2 = new DecimalFormat("#,##0.0#;(#,##0.0#)");
BigDecimal positive = new BigDecimal("123.45");
BigDecimal negative = positive.negate();
assertEquals(format1.format(positive), format2.format(positive));
assertEquals(format1.format(negative), format2.format(negative));
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The documentation should match what the code does. Or the code needs to match the documentation. I cannot tell which one is correct in this case.
ACTUAL -
That means that <code>"#,##0.0#;(#)"</code> produces precisely
* the same behavior as <code>"#,##0.0#;(#,##0.0#)"</code>.
URL OF FAULTY DOCUMENTATION :
http://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html
/**
* The {@link DecimalFormat} Javadoc says: <blockquote>That means that
* <code>"#,##0.0#;(#)"</code> produces precisely the same behavior as
* <code>"#,##0.0#;(#,##0.0#)"</code> .</blockquote>
*/
@Test
public void verifyDecimalFormatJavadoc() {
DecimalFormat format1 = new DecimalFormat("#,##0.0#;(#)");
DecimalFormat format2 = new DecimalFormat("#,##0.0#;(#,##0.0#)");
BigDecimal positive = new BigDecimal("123.45");
BigDecimal negative = positive.negate();
assertEquals(format1.format(positive), format2.format(positive));
assertEquals(format1.format(negative), format2.format(negative));
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The documentation should match what the code does. Or the code needs to match the documentation. I cannot tell which one is correct in this case.
ACTUAL -
That means that <code>"#,##0.0#;(#)"</code> produces precisely
* the same behavior as <code>"#,##0.0#;(#,##0.0#)"</code>.
URL OF FAULTY DOCUMENTATION :
http://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html
- duplicates
-
JDK-6609740 [Fmt-De] format error in DecimalFormat
- Resolved
-
JDK-8044849 DecimalFormat looses closing parenthesis when using (#) as negative subpattern
- Closed