java stringutils isnumeric,我的意思是StringUtils.isNumeric的替代方法吗?

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?

解决方案

Try isNumber(String) from org.apache.commons.lang.math.NumberUtils.

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

Valid numbers include hexadecimal marked with the 0x qualifier,

scientific notation and numbers marked with a type qualifier (e.g.

123L).

Null and empty String will return false.

UPDATE -

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

Thank you eav for pointing it out.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值