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

NumberFormat.parse doesn't return null

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.2.0
    • core-libs
    • generic
    • generic



      Name: bb33257 Date: 02/23/98


      The javadoc says that if NumberFormat.parse(String, ParsePosition)
      fails, it will return null. However, instead it is returning
      new Long(0) (or something like that).

      import java.text.*;

      public class Bug {
              public static void main(String[] args) {
                      NumberFormat format = NumberFormat.getInstance();
                      String text = "time 10:x";
                      ParsePosition pos = new ParsePosition(8);
                      Number result = format.parse(text, pos);
                      System.out.println(result); // Should be null; it isn't
              }
      }
      ======================================================================

            duke J. Duke
            bcbeck Brian Beck (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: