类 NumberUtils
java.lang.Object
com.alibaba.nacos.common.utils.NumberUtils
Number utils.
- 作者:
- zzq
-
方法概要
修饰符和类型方法说明static booleanChecks whether theStringcontains only digit characters.static doubleConvert aStringto adouble, returning a default value if the conversion fails.static floatConvert aStringto afloat, returning0.0fif the conversion fails.static floatConvert aStringto afloat, returning a default value if the conversion fails.static intConvert aStringto anint, returningzeroif the conversion fails.static intConvert aStringto anint, returning a default value if the conversion fails.static longConvert aStringto along, returning a default value if the conversion fails.
-
方法详细资料
-
toInt
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
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
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
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
Checks whether theStringcontains only digit characters.- 参数:
str- theStringto check- 返回:
trueif str contains only unicode numeric
-
toFloat
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
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
-