更新时间:2023-11-26 19:34:40
使用 Apache Commons Lang 3.5及以上: NumberUtils.isCreatable
或 StringUtils.isNumeric
。
With Apache Commons Lang 3.5 and above: NumberUtils.isCreatable
or StringUtils.isNumeric
.
Apache Commons Lang 3.4及以下: NumberUtils.isNumber
或 StringUtils .isNumeric
。
With Apache Commons Lang 3.4 and below: NumberUtils.isNumber
or StringUtils.isNumeric
.
您还可以使用 StringUtils.isNumericSpace
对于空字符串返回 true
并忽略字符串中的内部空格。 (链接的javadoc包含每个方法的详细示例。)
You can also use StringUtils.isNumericSpace
which returns true
for empty strings and ignores internal spaces in the string. (The linked javadocs contain detailed examples for each method.)