Apache.commons.lang3 的 isNumber 将会在 lang 4 的时候丢弃
在判断输入的字符串是不是一个数字的时候,我们通常用的最多的方法就是 :
NumberUtils.isNumber("12");
但是这个方法将会在 Lang 4.0 版本中被丢弃。
可以使用的替代方法为:isCreatable(String)
通过查看源代码,我们可以看到 isNumber 也是调用 isCreatable 方法的。

复制代码
isCreatable 方法首先是对输入的字符串拆分成字符,然后对每一个字符进行判断,以确定输入的字符串是不是数字,是不是可以将 String 转换为数字类型。

通过上面的方法,我们看到判断的方法还是有点复杂的。
https://www.ossez.com/t/apache-commons-lang3-isnumber-lang-4/13990
评论