|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.util.NumberUtils
Miscellaneous utility methos for number conversion and parsing. Mainly for internal use within the framework; consider Jakarta's Commons Lang for a more comprehensive suite of string utilities.
Constructor Summary | |
NumberUtils()
|
Method Summary | |
static Number |
convertNumberToTargetClass(Number number,
Class targetClass)
Convert the given number into an instance of the given target class. |
static Number |
parseNumber(String text,
Class targetClass)
Parse the given text into a number instance of the given target class, using the corresponding default valueOf methods. |
static Number |
parseNumber(String text,
Class targetClass,
NumberFormat numberFormat)
Parse the given text into a number instance of the given target class, using the given NumberFormat. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public NumberUtils()
Method Detail |
public static Number convertNumberToTargetClass(Number number, Class targetClass) throws IllegalArgumentException
number
- the number to converttargetClass
- the target class to convert to
IllegalArgumentException
- if the target class is not supported
(i.e. not a standard Number subclass as included in the JDK)Short
,
Integer
,
Long
,
BigInteger
,
Float
,
Double
,
BigDecimal
public static Number parseNumber(String text, Class targetClass)
valueOf
methods.
text
- the text to converttargetClass
- the target class to parse into
IllegalArgumentException
- if the target class is not supported
(i.e. not a standard Number subclass as included in the JDK)Short.valueOf(java.lang.String)
,
Integer.valueOf(java.lang.String)
,
Long.valueOf(java.lang.String)
,
BigInteger.BigInteger(String)
,
Float.valueOf(java.lang.String)
,
Double.valueOf(java.lang.String)
,
BigDecimal.BigDecimal(String)
public static Number parseNumber(String text, Class targetClass, NumberFormat numberFormat)
text
- the text to converttargetClass
- the target class to parse intonumberFormat
- the NumberFormat to use for parsing
IllegalArgumentException
- if the target class is not supported
(i.e. not a standard Number subclass as included in the JDK)NumberFormat.parse(java.lang.String)
,
convertNumberToTargetClass(java.lang.Number, java.lang.Class)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |