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

Numeric classes need static checker methods for Strings

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 7
    • core-libs
    • x86
    • windows_xp

      A DESCRIPTION OF THE REQUEST :
      The only way to check if a numeric String has a valid format is to try to parse it an catch the exception thrown. I'm requesting an easy way to make sure that a String has a valid numeric format.

      JUSTIFICATION :
      Writing this kind of code to perform a basic task, to find out the validity of a number, is not acceptable.

      boolean isNumeric = true; try{Integer.parseInt(fieldValue);}catch(Exception e){isNumeric = false;}

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      boolean isNumeric = Integer.isInt(s);

      boolean isNumeric = Integer.isInt(s,radix);

      Similar methods should be implemented in the Byte, Short, Integer, Long, Float and Double classes.

            darcy Joe Darcy
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: