public class Numbers extends Object
| 构造器和说明 |
|---|
Numbers() |
| 限定符和类型 | 方法和说明 |
|---|---|
static BigDecimal |
createBigDecimal(String str)
Convert a
String to a BigDecimal. |
static BigInteger |
createBigInteger(String str)
Convert a
String to a BigInteger. |
static Double |
createDouble(String str)
Convert a
String to a Double. |
static Float |
createFloat(String str)
Convert a
String to a Float. |
static Integer |
createInteger(String str) |
static Long |
createLong(String str)
Convert a
String to a Long. |
static Number |
createNumber(String str) |
static boolean |
isDigits(String str)
Checks whether the
String contains only
digit characters. |
static boolean |
isNumber(String str)
Checks whether the String a valid Java number.
|
public static Float createFloat(String str)
Convert a String to a Float.
Returns null if the string is null.
str - a String to convert, may be nullFloatNumberFormatException - if the value cannot be convertedpublic static Double createDouble(String str)
Convert a String to a Double.
Returns null if the string is null.
str - a String to convert, may be nullDoubleNumberFormatException - if the value cannot be convertedpublic static Long createLong(String str)
Convert a String to a Long.
Returns null if the string is null.
str - a String to convert, may be nullLongNumberFormatException - if the value cannot be convertedpublic static BigInteger createBigInteger(String str)
Convert a String to a BigInteger.
Returns null if the string is null.
str - a String to convert, may be nullBigIntegerNumberFormatException - if the value cannot be convertedpublic static BigDecimal createBigDecimal(String str)
Convert a String to a BigDecimal.
Returns null if the string is null.
str - a String to convert, may be nullBigDecimalNumberFormatException - if the value cannot be convertedpublic static boolean isDigits(String str)
Checks whether the String contains only
digit characters.
Null and empty String will return
false.
str - the String to checktrue if str contains only unicode numericpublic static boolean isNumber(String str)
Checks whether the String a valid Java number.
Valid numbers include hexadecimal marked with the 0x
qualifier, scientific notation and numbers marked with a type
qualifier (e.g. 123L).
Null and empty String will return
false.
str - the String to checktrue if the string is a correctly formatted numberpublic static Number createNumber(String str) throws NumberFormatException
Copyright © 2019. All rights reserved.