[ 
https://issues.apache.org/jira/browse/LANG-971?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13896901#comment-13896901
 ] 

Sebb commented on LANG-971:
---------------------------

Agreed, it's not consistent with the create*() methods.

Assuming that a "valid Java number" is a sequence of digits that is valid as a 
constant initialiser, then "0085" should be rejected, as it is not valid to 
write:

{code}
int value = 0085; // compiler error
int pat = Integer.decode("0085"); // NumberFormatException
{code}

However, "0085" is valid in other contexts, for example 
Integer.parseInt("0085");

Having said that, the unit tests suggest that isNumber() and createNumber() 
should be consistent.

> NumberUtils#isNumber(String) fails to evaluate invalid Octal numbers
> --------------------------------------------------------------------
>
>                 Key: LANG-971
>                 URL: https://issues.apache.org/jira/browse/LANG-971
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.math.*
>    Affects Versions: 3.2.1
>            Reporter: Stephan Knitelius
>            Priority: Minor
>
> When trying to convert "0085" with NumberUtils.createInteger(String) an 
> NumberFormatException is thrown. 
> This is because the leading 0 causes the String to be evaluated as an Octal, 
> 8 is not a valid octal.
> However NumberUtils#isNumber(String) evaluates to true, even so it cannot be 
> converted.  



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to