commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rob Tompkins (JIRA)" <>
Subject [jira] [Commented] (LANG-1252) NumberUtils.isNumber and NumberUtils.createNumber resolve inconsistently
Date Sun, 11 Sep 2016 00:25:20 GMT


Rob Tompkins commented on LANG-1252:

In Java 1.6 
throws the following exception
java.lang.NumberFormatException: For input string: "+2"

	at java.lang.NumberFormatException.forInputString(
	at java.lang.Integer.parseInt(
	at java.math.BigInteger.<init>(
	at org.apache.commons.lang3.math.NumberUtils.createBigInteger(
	at org.apache.commons.lang3.math.NumberUtils.createNumber(

In Java 1.7 the call succeeds.

> NumberUtils.isNumber and NumberUtils.createNumber resolve inconsistently
> ------------------------------------------------------------------------
>                 Key: LANG-1252
>                 URL:
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.math.*
>    Affects Versions: 3.4
>            Reporter: Rob Tompkins
>            Assignee: Rob Tompkins
>             Fix For: Discussion
> In considering the issues LANG-1060, LANG-1040, LANG-1038, and LANG-992, it seems that
there are times when {{NumberUtils.isNumber}} resolves to {{false}} while {{NumberUtils.createNumber}},
given the same input, does not throw an exception, returning a valid {{java.lang.Number}}.
This inconsistency should be resolved either by making {{isNumber}} more lenient or {{createNumber}}
more stringent.

This message was sent by Atlassian JIRA

View raw message