You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Stephan Knitelius (JIRA)" <ji...@apache.org> on 2014/02/10 09:09:19 UTC
[jira] [Commented] (LANG-968) NumberUtils#createInteger(String) NFE
with multiple leading zeros
[ https://issues.apache.org/jira/browse/LANG-968?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13896300#comment-13896300 ]
Stephan Knitelius commented on LANG-968:
----------------------------------------
Didn't think about octal numbers, hence stripping leading zeros is not an option.
Yes using trim on the input String would do what I want, however it would be nicer if this was done by NumberUtils#create*(String).
> NumberUtils#createInteger(String) NFE with multiple leading zeros
> -----------------------------------------------------------------
>
> Key: LANG-968
> URL: https://issues.apache.org/jira/browse/LANG-968
> Project: Commons Lang
> Issue Type: Improvement
> Components: lang.math.*
> Affects Versions: 3.2.1
> Reporter: Stephan Knitelius
> Priority: Minor
>
> 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.
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)