blank is numeric, but blank is not numeric?!

Someone please explain this piece of sheer lunacy in apache commons-lang’s (otherwise superb) StringUtils

From the docs

 StringUtils.isNumeric(null)   = false
 StringUtils.isNumeric("")     = true
 StringUtils.isNumeric("  ")   = false

Insanity. I can only assume this was an error in the old code, and is now preserved for backward compatibility. :(

What you want instead is NumberUtils.isNumber()

Comments are closed.