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

java.text.DecimalFormat.parse returns 0 if string parameter is incorrect.

XMLWordPrintable

    • 1.2beta4
    • generic, sparc
    • generic, solaris_2.5
    • Verified



      Name: dfC67450 Date: 01/26/98



      java.text.DecimalFormat.parse(String str, ParsePosition pp) returns 0 if string
      parameter is incorrect. For consistency with previous JDK version it should return
      null.
       
      Here is the test demonstrating the bug:

      -----------------Test.java------------------------
      import java.text.*;

      public class Test {
          public static void main (String args[]){
              DecimalFormat df = new DecimalFormat();
              String text = "x";

              System.out.println("pattern: \"" + df.toPattern() + "\"");
              System.out.println("\"" + text + "\" is parsed as " +
                                 df.parse(text, new ParsePosition(0)));

          }
      }

      --------- Output from the test for JDK1.1.6 ---------------------
      pattern: "#,##0.###"
      "x" is parsed as 0
      --------- Output from the test for JDK1.1.5 ---------------------
      pattern: "#,##0.###"
      "x" is parsed as null
      --------------------------------------------------

      ======================================================================

            duke J. Duke
            dfazunensunw Dmitri Fazunenko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: