public final class NumberUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static double |
getDouble(Object object)
remove all non-digit character form string, if remain string not empty,
return double value of that, else return 0
|
static Long |
getLastDigit(long number,
int countOfLastDigit) |
static Set<Long> |
getNumbers(String string) |
static Set<Long> |
getNumeric(Collection<String> collection) |
static Long |
getNumeric(Object num) |
static Long |
getNumeric(String num)
remove all non-digit character (not minus in start if string '-') form
string, if remain string not empty, return long value of that, else
return 0
|
static int |
toInt(String str,
int defaultValue)
Convert a
String to a 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. |
public static Long getLastDigit(long number, int countOfLastDigit)
public static Long getNumeric(String num)
public static Long getNumeric(Object num)
public static Set<Long> getNumeric(Collection<String> collection)
public static double getDouble(Object object)
public static Set<Long> getNumbers(String string)
public static long toLong(String str, long defaultValue)
Convert a String to a long, returning a default value if the conversion fails.
If the string is null, the default value is returned.
NumberUtils.toLong(null, 1L) = 1L
NumberUtils.toLong("", 1L) = 1L
NumberUtils.toLong("1", 0L) = 1L
str - the string to convert, may be nulldefaultValue - the default valuepublic static int toInt(String str, int defaultValue)
Convert a String to a int, returning a default value if the conversion fails.
If the string is null, the default value is returned.
NumberUtils.toInt(null, 1) = 1
NumberUtils.toInt("", 1) = 1
NumberUtils.toInt("1", 0) = 1
str - the string to convert, may be nulldefaultValue - the default valueCopyright © 2020. All rights reserved.