我有什么意思代替StringUtils.isNumeric吗? [英] Is there an alternative to StringUtils.isNumeric that does what I mean?

查看:313
本文介绍了我有什么意思代替StringUtils.isNumeric吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

StringUtils.isNumeric对于"返回true,对于7.8返回false.这当然是记录在案的行为,但对我而言确实不是最方便的.还有其他东西(最好在commons.lang中)提供isActuallyNumeric吗?

StringUtils.isNumeric returns true for "" and false for 7.8. This is of course it's documented behavior, but really not the most convenient for me. Is there something else (ideally in commons.lang) that provides an isActuallyNumeric?

推荐答案

尝试

检查字符串[是否]是有效的Java数字.

Checks whether the String [is] a valid Java number.

有效数字包括标有0x限定词的十六进制, 科学符号和带有类型限定符的数字(例如 123L).

Valid numbers include hexadecimal marked with the 0x qualifier, scientific notation and numbers marked with a type qualifier (e.g. 123L).

Null和空字符串将返回false.

更新-

isNumber(String)现在已弃用.使用

isNumber(String) is now deprecated. Use isCreatable(String) instead.

谢谢 eav 指出来.

这篇关于我有什么意思代替StringUtils.isNumeric吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆