public final class NumUtil extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static char[] |
HEX_CHARS
16 进制数组
|
| 限定符和类型 | 方法和说明 |
|---|---|
static Number |
getFormatNum(String number,
String format)
获取格式化数字
|
static <T> T |
getFormatNum(String number,
String format,
Class<T> numberClazz)
获取格式化数字
|
static Object |
getFormatNumCast(String numberStr,
String format,
Class numberClazz)
获取类型转换后的金额
|
static int |
getMax(int current,
int other)
获取较大的结果
|
static int |
getMin(int current,
int other)
获取较小的结果
|
static String |
getNumFormat(Number number,
String format)
获取数字格式化
|
static boolean |
isHex(String string)
是否为 16 进制信息
|
static Long |
parseLong(Object object)
将对象转换为 Long
|
static Optional<Double> |
toDouble(String string)
转为 Double
|
static Optional<Integer> |
toInteger(String string)
转为 int
|
static int |
toInteger(String string,
int defaultValue)
转换为整形
(1)如果参数不合法,直接使用默认值
|
static Integer |
toIntegerThrows(String string)
字符串转化为整形
(1)如果参数不合法,直接抛出异常
|
static Optional<Long> |
toLong(String string)
转为 Long
|
public static int getMin(int current,
int other)
current - 当前值other - 其他值public static int getMax(int current,
int other)
current - 当前值other - 其他值public static Optional<Integer> toInteger(String string)
string - 原始字符串public static Integer toIntegerThrows(String string)
string - 字符串public static int toInteger(String string, int defaultValue)
string - 字符串defaultValue - 默认值public static Optional<Long> toLong(String string)
string - 原始字符串public static Optional<Double> toDouble(String string)
string - 原始字符串public static boolean isHex(String string)
string - 结果public static Long parseLong(Object object)
object - 对象ClassCastException - 类型转换异常CharSequence,
BigDecimal,
BigInteger,
Integer,
Short,
Byte,
Longpublic static String getNumFormat(Number number, String format)
number - 数字format - 格式化public static <T> T getFormatNum(String number, String format, Class<T> numberClazz)
T - 泛型number - 数字format - 格式化numberClazz - 数字类型public static Number getFormatNum(String number, String format)
number - 数字format - 格式化Copyright © 2020. All rights reserved.