Java lang3的 StringUtils.isNumeric(str)不能识别负数和小数

Java lang3的 StringUtils.isNumeric(str)不能识别负数和小数。

  1.  
    StringUtils.isNumeric(null) = false
  2.  
    * StringUtils.isNumeric("") = false
  3.  
    * StringUtils.isNumeric(" ") = false
  4.  
    * StringUtils.isNumeric("123") = true
  5.  
    * StringUtils.isNumeric("\u0967\u0968\u0969") = true
  6.  
    * StringUtils.isNumeric("12 3") = false
  7.  
    * StringUtils.isNumeric("ab2c") = false
  8.  
    * StringUtils.isNumeric("12-3") = false
  9.  
    * StringUtils.isNumeric("12.3") = false
  10.  
    * StringUtils.isNumeric("-123") = false
  11.  
    * StringUtils.isNumeric("+123") = false

 

如果想判断各种数字类型,用

NumberUtils.isCreatable(str)
posted @ 2021-02-20 11:07  marxtsui  阅读(1381)  评论(0编辑  收藏  举报