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)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM