Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-968

NumberUtils#createInteger(String) NFE with multiple leading zeros

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Not A Problem
    • Affects Version/s: 3.2.1
    • Fix Version/s: None
    • Component/s: lang.math.*
    • Labels:
      None

      Description

      When trying to convert the String "0085" to an Integer I get the following numberFormatException:

      java.lang.NumberFormatException: For input string: "085"

      Looking at the code reveals that only a null check is preformed before delegating to Integer#decode.

      It would be nice if the NumberUtil classes create* Methods would offer some more support:

      • remove leading and traling spaces.
      • remove leading zeros.

      Note: this would also be in line with NumberUtils#isNumber(String) - this method evaluates "0085" as true.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              sknitelius Stephan Knitelius
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: