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

NumberUtils#isParsable method(s)

    XMLWordPrintableJSON

    Details

    • Type: Wish
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.4
    • Component/s: lang.math.*
    • Labels:
      None

      Description

      (for background see LANG-997)

      It would be nice to have an isParseable method (or whatever it may be called), to be able to identify valid (=parseable) Numbers, something along the lines toDouble(String) / toLong(String) etc., but returning true / false while avoiding at the same time the try/catch(NumberFormatException) of those methods.

      This method would be similar to isNumber, but it should yield true for invalid octals like "018" which are parseable as Numbers. The point of this method is to identify "human" (neither hex nor octal, but should handle decimal points) numbers stored as Strings,

      We are using NumberUtils#isNumber to identify valid (parseable, human) numbers, but as of 3.3, this method also handles octal numbers, so, f.ex., 018, which was recognized as a valid number, isn't recognized anymore as one.

        Attachments

        1. LANG-1016_handling-negatives.patch
          2 kB
          Juan Pablo Santos Rodríguez
        2. LANG-1016.patch
          3 kB
          Juan Pablo Santos Rodríguez

          Issue Links

            Activity

              People

              • Assignee:
                britter Benedikt Ritter
                Reporter:
                juanpablo Juan Pablo Santos Rodríguez
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: