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

Allow signed positive integer to be parsed instead of a NumerFormatException

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 1.4.2, 5.0, 6u22
    • Fix Version/s: 7
    • Component/s: core-libs
    • Subcomponent:
    • Resolved In Build:
      b03
    • CPU:
      x86
    • OS:
      windows_xp
    • Verification:
      Not verified

      Backports

        Description

        Name: gm110360 Date: 03/22/2004


        A DESCRIPTION OF THE REQUEST :
        Integer.parseInt("+12") throws a NumberFormatException while
        Integer.parseInt("-12") return a correct value.


        JUSTIFICATION :
        Please allow the parsing of explicit signed positive integer for getting coherence and better lisibility in the processing of int, otherwise one has to write

        if (stringNumber.charAt(0) == '+') {
               Integer.parseInt(stringNumber.substring(1));
        } else {
              Integer.parseInt(stringNumber);
        }


        This enhancement applies also to Byte, Short and Long

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Integer.parseInt should return the right value for an explicitly positive signed integer.
        ACTUAL -
        throws NumberFormatException
        (Incident Review ID: 244493)
        ======================================================================
        ###@###.### 10/28/04 00:53 GMT

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                darcy Joe Darcy
                Reporter:
                gmanwanisunw Girish Manwani (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: