类 NumberUtils


  • public class NumberUtils
    extends java.lang.Object
    Number utils.
    作者:
    zzq
    • 构造器概要

      构造器 
      构造器 说明
      NumberUtils()  
    • 方法概要

      所有方法 静态方法 具体方法 
      修饰符和类型 方法 说明
      static boolean isDigits​(java.lang.String str)
      Checks whether the String contains only digit characters.
      static double toDouble​(java.lang.String str, double defaultValue)
      Convert a String to a double, returning a default value if the conversion fails.
      static float toFloat​(java.lang.String str)
      Convert a String to a float, returning 0.0f if the conversion fails.
      static float toFloat​(java.lang.String str, float defaultValue)
      Convert a String to a float, returning a default value if the conversion fails.
      static int toInt​(java.lang.String str)
      Convert a String to an int, returning zero if the conversion fails.
      static int toInt​(java.lang.String str, int defaultValue)
      Convert a String to an int, returning a default value if the conversion fails.
      static long toLong​(java.lang.String str, long defaultValue)
      Convert a String to a long, returning a default value if the conversion fails.
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 构造器详细资料

      • NumberUtils

        public NumberUtils()
    • 方法详细资料

      • toInt

        public static int toInt​(java.lang.String str)
        Convert a String to an int, returning zero if the conversion fails.
        参数:
        str - the string to convert, may be null
        返回:
        the int represented by the string, or zero if conversion fails
      • toInt

        public static int toInt​(java.lang.String str,
                                int defaultValue)
        Convert a String to an int, returning a default value if the conversion fails.
        参数:
        str - the string to convert, may be null
        defaultValue - the default value
        返回:
        the int represented by the string, or the default if conversion fails
      • toLong

        public static long toLong​(java.lang.String str,
                                  long defaultValue)
        Convert a String to a long, returning a default value if the conversion fails.
        参数:
        str - the string to convert, may be null
        defaultValue - the default value
        返回:
        the long represented by the string, or the default if conversion fails
      • toDouble

        public static double toDouble​(java.lang.String str,
                                      double defaultValue)
        Convert a String to a double, returning a default value if the conversion fails.
        参数:
        str - the string to convert, may be null
        defaultValue - the default value
        返回:
        the double represented by the string, or defaultValue if conversion fails
      • isDigits

        public static boolean isDigits​(java.lang.String str)
        Checks whether the String contains only digit characters.
        参数:
        str - the String to check
        返回:
        true if str contains only unicode numeric
      • toFloat

        public static float toFloat​(java.lang.String str)
        Convert a String to a float, returning 0.0f if the conversion fails.
        参数:
        str - the string to convert, may be null
        返回:
        the float represented by the string, or 0.0f if conversion fails
      • toFloat

        public static float toFloat​(java.lang.String str,
                                    float defaultValue)
        Convert a String to a float, returning a default value if the conversion fails.
        参数:
        str - the string to convert, may be null
        defaultValue - the default value
        返回:
        the float represented by the string, or defaultValue if conversion fails