源代码:

/**
     * <p>Checks if the String contains only unicode digits.
     * A decimal point is not a unicode digit and returns false.</p>
     *
     * <p><code>null</code> will return <code>false</code>.
     * An empty String (length()=0) will return <code>true</code>.</p>
     *
     * <pre>
     * StringUtils.isNumeric(null)   = false
     * StringUtils.isNumeric("")     = true
     * StringUtils.isNumeric("  ")   = false
     * StringUtils.isNumeric("123")  = true
     * StringUtils.isNumeric("12 3") = false
     * StringUtils.isNumeric("ab2c") = false
     * StringUtils.isNumeric("12-3") = false
     * StringUtils.isNumeric("12.3") = false
     * </pre>
     *
     * @param str  the String to check, may be null
     * @return <code>true</code> if only contains digits, and is non-null
     */
    public static boolean isNumeric(String str) {
        if (str == null) {
            return false;
        }
        int sz = str.length();
        for (int i = 0; i < sz; i++) {
            if (Character.isDigit(str.charAt(i)) == false) {
                return false;
            }
        }
        return true;
    }

 

 

https://issues.apache.org/jira/browse/LANG-428

  • Type: Bug
  • Status: Closed
  • Priority: Minor
  • Resolution: Fixed
  • Affects Version/s: 2.3
  • Fix Version/s: 3.0
  • Component/s: lang.*
  • Labels:
    None

3.0版本已经解决该问题

相关文章:

  • 2021-12-04
  • 2021-09-20
  • 2021-10-10
  • 2021-06-27
  • 2022-12-23
  • 2022-12-23
  • 2021-09-08
  • 2022-12-23
猜你喜欢
  • 2022-01-02
  • 2022-12-23
  • 2021-08-25
  • 2021-11-03
  • 2022-01-01
  • 2021-06-12
相关资源
相似解决方案