Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6213123

[Fmt-Nu] DecimalFormat applies pattern "#" incorrectly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 5.0
    • core-libs
    • x86
    • windows_2000

      FULL PRODUCT VERSION :
      java version "1.5.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
      Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      DecimalFormat applies pattern "#" incorrectly

      This pattern implies that the number should only be passed as an Integer, however DecimalFormat also allows for decimal numbers to be parsed with this pattern.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      run code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      true to be displayed
      ACTUAL -
      false is displayed

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import static java.lang.System.*;
      import java.text.*;

      public class Test {
        public static void main(String[] args) {
          out.println(new DecimalFormat("#").isParseIntegerOnly());
        }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Call setParseIntegerOnly(true) on the format after applying the pattern.
      ###@###.### 2004-12-30 10:02:44 GMT

            jlu Justin Lu
            jssunw Jitender S (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: