public class NumberUtil extends Object
| Constructor and Description |
|---|
NumberUtil() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
equalsWithin(double d1,
double d2)
因为double的精度问题, 允许两个double在0.00001内的误差为相等。
|
static boolean |
equalsWithin(double d1,
double d2,
double epsilon)
因为double的精度问题, 允许两个double在epsilon内的误差为相等
|
static Integer |
hexToIntObject(String str)
将16进制的String转化为Integer.
|
static Integer |
hexToIntObject(String str,
Integer defaultValue)
将16进制的String转化为Integer,出错时返回默认值.
|
static Long |
hexToLongObject(String str)
将16进制的String转化为Long
当str为空或非数字字符串时抛NumberFormatException
|
static Long |
hexToLongObject(String str,
Long defaultValue)
将16进制的String转化为Long,出错时返回默认值.
|
static boolean |
isHexNumber(String value)
判断字符串是否16进制
|
static boolean |
isNumber(String str)
判断字符串是否合法数字
|
static String |
to2DigitString(double d)
输出格式化为小数后两位的double字符串
|
static byte[] |
toBytes(double val)
copy from ElasticSearch Numbers
|
static byte[] |
toBytes(int value) |
static byte[] |
toBytes(long value) |
static double |
toDouble(byte[] bytes)
copy from ElasticSearch Numbers
|
static double |
toDouble(String str)
将10进制的String安全的转化为double.
|
static double |
toDouble(String str,
double defaultValue)
将10进制的String安全的转化为double.
|
static Double |
toDoubleObject(String str)
将10进制的String安全的转化为Double.
|
static Double |
toDoubleObject(String str,
Double defaultValue)
将10进制的String安全的转化为Long.
|
static int |
toInt(byte[] bytes) |
static int |
toInt(String str)
将10进制的String转化为int.
|
static int |
toInt(String str,
int defaultValue)
将10进制的String安全的转化为int.
|
static int |
toInt32(long x)
安全的将小于Integer.MAX的long转为int,否则抛出IllegalArgumentException异常
|
static Integer |
toIntObject(String str)
将10进制的String安全的转化为Integer.
|
static Integer |
toIntObject(String str,
Integer defaultValue)
将10进制的String安全的转化为Integer.
|
static long |
toLong(byte[] bytes) |
static long |
toLong(String str)
将10进制的String安全的转化为long.
|
static long |
toLong(String str,
long defaultValue)
将10进制的String安全的转化为long.
|
static Long |
toLongObject(String str)
将10进制的String安全的转化为Long.
|
static Long |
toLongObject(String str,
Long defaultValue)
将10进制的String安全的转化为Long.
|
static String |
toString(double d) |
static String |
toString(Double d) |
static String |
toString(int i) |
static String |
toString(Integer i) |
static String |
toString(long l) |
static String |
toString(Long l) |
public static boolean equalsWithin(double d1,
double d2)
public static boolean equalsWithin(double d1,
double d2,
double epsilon)
public static byte[] toBytes(int value)
public static byte[] toBytes(long value)
public static byte[] toBytes(double val)
public static int toInt(byte[] bytes)
public static long toLong(byte[] bytes)
public static double toDouble(byte[] bytes)
public static boolean isNumber(String str)
public static boolean isHexNumber(String value)
public static int toInt(String str)
public static int toInt(String str, int defaultValue)
public static long toLong(String str)
public static long toLong(String str, long defaultValue)
public static double toDouble(String str)
public static double toDouble(String str, double defaultValue)
public static Integer toIntObject(String str)
public static Integer toIntObject(String str, Integer defaultValue)
public static Long toLongObject(String str)
public static Long toLongObject(String str, Long defaultValue)
public static Double toDoubleObject(String str)
public static Double toDoubleObject(String str, Double defaultValue)
public static Integer hexToIntObject(String str)
public static Integer hexToIntObject(String str, Integer defaultValue)
public static Long hexToLongObject(String str)
public static Long hexToLongObject(String str, Long defaultValue)
public static String toString(int i)
public static String toString(long l)
public static String toString(double d)
public static String to2DigitString(double d)
public static int toInt32(long x)
Copyright © 2018. All rights reserved.