[
https://issues.apache.org/jira/browse/LANG-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14146331#comment-14146331
]
Duncan Jones commented on LANG-1038:
------------------------------------
The Javadocs for {{isNumber()}} state (from trunk):
bq. Valid numbers include hexadecimal marked with the {{0x}} or {{0X}}
qualifier, octal numbers, scientific notation and numbers marked with a type
qualifier (e.g. 123L).
There is nothing there that suggests a relationship to the equivalent parse
function from {{Integer}} or any other class. Nor is there anything that
suggests a leading {{+}} sign is supported.
Consequently, I'd suggest this is an Improvement, not a Bug. We should discuss
whether a change in behaviour is welcome.
> NumberUtils#isNumber() returns false for "+2" and true for "-2"
> ---------------------------------------------------------------
>
> Key: LANG-1038
> URL: https://issues.apache.org/jira/browse/LANG-1038
> Project: Commons Lang
> Issue Type: Bug
> Components: lang.math.*
> Affects Versions: 3.1, 3.3.2
> Reporter: will mason
> Fix For: Discussion
>
>
> The strings {{"\+2"}} and {{"\+ 2"}} give a "False" result when tested by
> {{isNumber()}}.
> Case one, {{"\+2"}} is legal with {{Integer.parseInt()}}. Case two: {{"\+
> 2"}} gives an exception with {{Integer.parseInt()}}.
> I believe the function should match legitimate inputs for the respective
> parser function depending on the number type.
> Workaround: Use something like:
> {code:java}
> NumberUtils.isNumber( wrkStr.replaceFirst( "\\+", "") )
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)