Javadoc of java.text.DecimalFormat is wrong

XMLWordPrintable

    • Type: Bug
    • Resolution: Duplicate
    • Priority: P4
    • None
    • Affects Version/s: 7u75
    • Component/s: core-libs
    • x86
    • windows_8

      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

            Assignee:
            Yuka Kamiya (Inactive)
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: