public class NumberUtil
extends org.springframework.util.NumberUtils
| Constructor and Description |
|---|
NumberUtil() |
| Modifier and Type | Method and Description |
|---|---|
static long |
form62Str(String s)
将 62 进制字符串转为数字
|
static String |
to62Str(long i)
将 long 转短字符串 为 62 进制
|
static int |
toInt(String str)
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)
Convert a
String to a long, returning
zero 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 int toInt(String str)
Convert a String to an int, returning
zero if the conversion fails.
If the string is null, zero is returned.
NumberUtil.toInt(null) = 0
NumberUtil.toInt("") = 0
NumberUtil.toInt("1") = 1
str - the string to convert, may be nullzero if
conversion failspublic static int toInt(@Nullable
String str,
int defaultValue)
Convert a String to an int, returning a
default value if the conversion fails.
If the string is null, the default value is returned.
NumberUtil.toInt(null, 1) = 1
NumberUtil.toInt("", 1) = 1
NumberUtil.toInt("1", 0) = 1
str - the string to convert, may be nulldefaultValue - the default valuepublic static long toLong(String str)
Convert a String to a long, returning
zero if the conversion fails.
If the string is null, zero is returned.
NumberUtil.toLong(null) = 0L
NumberUtil.toLong("") = 0L
NumberUtil.toLong("1") = 1L
str - the string to convert, may be null0 if
conversion failspublic static long toLong(@Nullable
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.
NumberUtil.toLong(null, 1L) = 1L
NumberUtil.toLong("", 1L) = 1L
NumberUtil.toLong("1", 0L) = 1L
str - the string to convert, may be nulldefaultValue - the default valuepublic static String to62Str(long i)
i - 数字public static long form62Str(String s)
s - 字符串Copyright © 2024. All rights reserved.