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

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

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.2beta4
    • CPU:
      generic, sparc
    • OS:
      generic, solaris_2.5
    • Verification:
      Verified

      Description



      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
      --------------------------------------------------

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

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: