JDK-8072449 : Javadoc of java.text.DecimalFormat is wrong
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.text
  • Affected Version: 7u75
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_8
  • CPU: x86
  • Submitted: 2015-02-03
  • Updated: 2017-01-13
  • Resolved: 2015-02-10
Related Reports
Duplicate :  
Duplicate :  
Description
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