Top Description Constructors Methods
liquibase.util

public abstract Class NumberUtil

extends Object
Class Inheritance
Known Direct Subclasses
liquibase.util.NumberUtils
Imports
java.math.BigDecimal, .BigInteger

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

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static Number
convertNumberToTargetClass(Number number, Class<T> targetClass)

Convert the given number into an instance of the given target class.

public static Number

Returns:

the parsed number
parseNumber
(String
the text to convert
text
,
Class<T>
the target class to parse into
targetClass
)

Parse the given text into a number instance of the given target class, using the corresponding default decode methods.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

NumberUtilback to summary
public NumberUtil()

Method Detail

convertNumberToTargetClassback to summary
public static Number convertNumberToTargetClass(Number number, Class<T> targetClass) throws IllegalArgumentException

Convert the given number into an instance of the given target class.

parseNumberback to summary
public static Number parseNumber(String text, Class<T> targetClass)

Parse the given text into a number instance of the given target class, using the corresponding default decode methods. Trims the input String before attempting to parse the number. Supports numbers in hex format (with leading 0x) and in octal format (with leading 0).

Parameters
text:String

the text to convert

targetClass:Class<T>

the target class to parse into

Returns:Number

the parsed number

Exceptions
IllegalArgumentException:
if the target class is not supported (i.e. not a standard Number subclass as included in the JDK)
See Also
java.lang.Byte#decode, java.lang.Short#decode, java.lang.Integer#decode, java.lang.Long#decode, java.lang.Float#valueOf, java.lang.Double#valueOf, java.math.BigDecimal#BigDecimal(String)