RSS Feed for This PostCurrent Article

Java: StringUtils.isNumeric with Decimal Point

For the code snippet

   1: System.out.println(StringUtils.isNumeric("10.0"));

Using Apache Commons Lang, the above will return false. This is one bug I recently found in one of the existing application.

As quoted from the documentation, StringUtils.isNumeric

Checks if the String contains only unicode digits. A decimal point is not a unicode digit and returns false.

To return the correct result, you should use NumberUtils.isNumber


Trackback URL


Sorry, comments for this entry are closed at this time.