Package liquibase.util
Class NumberUtil
- java.lang.Object
-
- liquibase.util.NumberUtil
-
- Direct Known Subclasses:
NumberUtils
public abstract class NumberUtil extends Object
Miscellaneous utility methods 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
Constructors Constructor Description NumberUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static Number
convertNumberToTargetClass(Number number, Class targetClass)
Deprecated.static Number
parseNumber(String text, Class targetClass)
Parse the given text into a number instance of the given target class, using the corresponding defaultdecode
methods.
-
-
-
Method Detail
-
convertNumberToTargetClass
public static Number convertNumberToTargetClass(Number number, Class targetClass) throws IllegalArgumentException
Deprecated.Convert the given number into an instance of the given target class.- Throws:
IllegalArgumentException
-
parseNumber
public static Number parseNumber(String text, Class targetClass)
Parse the given text into a number instance of the given target class, using the corresponding defaultdecode
methods. Trims the inputString
before attempting to parse the number. Supports numbers in hex format (with leading 0x) and in octal format (with leading 0).- Parameters:
text
- the text to converttargetClass
- the target class to parse into- Returns:
- the parsed number
- Throws:
IllegalArgumentException
- if the target class is not supported (i.e. not a standard Number subclass as included in the JDK)- See Also:
Byte.decode(java.lang.String)
,Short.decode(java.lang.String)
,Integer.decode(java.lang.String)
,Long.decode(java.lang.String)
,Float.valueOf(java.lang.String)
,Double.valueOf(java.lang.String)
,BigDecimal(String)
-
-