类 NumberUtils

java.lang.Object
com.alibaba.nacos.common.utils.NumberUtils

public class NumberUtils extends Object
Number utils.
作者:
zzq
  • 方法概要

    修饰符和类型
    方法
    说明
    static boolean
    Checks whether the String contains only digit characters.
    static double
    toDouble(String str, double defaultValue)
    Convert a String to a double, returning a default value if the conversion fails.
    static float
    Convert a String to a float, returning 0.0f if the conversion fails.
    static float
    toFloat(String str, float defaultValue)
    Convert a String to a float, returning a default value if the conversion fails.
    static int
    Convert a String to an int, returning zero if the conversion fails.
    static int
    toInt(String str, int defaultValue)
    Convert a String to an int, returning a default value if the conversion fails.
    static long
    toLong(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
  • 方法详细资料

    • toInt

      public static int toInt(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(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(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(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(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(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(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