类 NumberUtils
- java.lang.Object
-
- com.alibaba.nacos.common.utils.NumberUtils
-
public class NumberUtils extends java.lang.ObjectNumber utils.- 作者:
- zzq
-
-
构造器概要
构造器 构造器 说明 NumberUtils()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static booleanisDigits(java.lang.String str)Checks whether theStringcontains only digit characters.static doubletoDouble(java.lang.String str, double defaultValue)Convert aStringto adouble, returning a default value if the conversion fails.static floattoFloat(java.lang.String str)Convert aStringto afloat, returning0.0fif the conversion fails.static floattoFloat(java.lang.String str, float defaultValue)Convert aStringto afloat, returning a default value if the conversion fails.static inttoInt(java.lang.String str)Convert aStringto anint, returningzeroif the conversion fails.static inttoInt(java.lang.String str, int defaultValue)Convert aStringto anint, returning a default value if the conversion fails.static longtoLong(java.lang.String str, long defaultValue)Convert aStringto along, returning a default value if the conversion fails.
-
-
-
方法详细资料
-
toInt
public static int toInt(java.lang.String str)
Convert aStringto anint, returningzeroif the conversion fails.- 参数:
str- the string to convert, may be null- 返回:
- the int represented by the string, or
zeroif conversion fails
-
toInt
public static int toInt(java.lang.String str, int defaultValue)Convert aStringto anint, returning a default value if the conversion fails.- 参数:
str- the string to convert, may be nulldefaultValue- 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 aStringto along, returning a default value if the conversion fails.- 参数:
str- the string to convert, may be nulldefaultValue- 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 aStringto adouble, returning a default value if the conversion fails.- 参数:
str- the string to convert, may benulldefaultValue- 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 theStringcontains only digit characters.- 参数:
str- theStringto check- 返回:
trueif str contains only unicode numeric
-
toFloat
public static float toFloat(java.lang.String str)
Convert aStringto afloat, returning0.0fif the conversion fails.- 参数:
str- the string to convert, may benull- 返回:
- the float represented by the string, or
0.0fif conversion fails
-
toFloat
public static float toFloat(java.lang.String str, float defaultValue)Convert aStringto afloat, returning a default value if the conversion fails.- 参数:
str- the string to convert, may be nulldefaultValue- the default value- 返回:
- the float represented by the string, or defaultValue if conversion fails
-
-