[
https://issues.apache.org/jira/browse/LANG-1038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14244725#comment-14244725
]
haiyang li edited comment on LANG-1038 at 12/12/14 8:26 PM:
------------------------------------------------------------
I agree with what Duncan Jones said in LANG-1040. whether it's a improvement
or bug doesn't matter. The more important thing is to "Always try to keep
consistent". it will make the APIs easily to understand/use. and make the
future design decision not so difficult to make.
personally, i prefer to replace code with:
{code}
try {
createNumber(str);
return true;
} catch (NumberFormatException e) {
return false;
}
{code}
was (Author: lihy70):
I agree with what Duncan Jones said in LANG-1040. whether it's a improvement
or bug doesn't matter. The more important thing is to "Always try to keep
consistent". it will make the APIs easily to understand/use. and make the
future design decision not so difficult to make.
personally, i prefer to replace code with:
{code}
try {
createNumber(str);
return true;
} catch (Exception e) {
return false;
}
{code}
> 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)