net.hasor.jdbc.core.util
类 NumberUtils

java.lang.Object
  继承者 net.hasor.jdbc.core.util.NumberUtils

public abstract class NumberUtils
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.

从以下版本开始:
1.1.2
作者:
Juergen Hoeller, Rob Harrop

构造方法摘要
NumberUtils()
           
 
方法摘要
static
<T extends Number>
T
convertNumberToTargetClass(Number number, Class<T> targetClass)
          Convert the given number into an instance of the given target class.
static boolean isNumber(String index)
           
static
<T extends Number>
T
parseNumber(String text, Class<T> targetClass)
          Parse the given text into a number instance of the given target class, using the corresponding decode / valueOf methods.
static
<T extends Number>
T
parseNumber(String text, Class<T> targetClass, NumberFormat numberFormat)
          Parse the given text into a number instance of the given target class, using the given NumberFormat.
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

NumberUtils

public NumberUtils()
方法详细信息

convertNumberToTargetClass

public static <T extends Number> T convertNumberToTargetClass(Number number,
                                                              Class<T> targetClass)
                                                   throws IllegalArgumentException
Convert the given number into an instance of the given target class.

参数:
number - the number to convert
targetClass - the target class to convert to
返回:
the converted number
抛出:
IllegalArgumentException - if the target class is not supported (i.e. not a standard Number subclass as included in the JDK)
另请参见:
Byte, Short, Integer, Long, BigInteger, Float, Double, BigDecimal

parseNumber

public static <T extends Number> T parseNumber(String text,
                                               Class<T> targetClass)
Parse the given text into a number instance of the given target class, using the corresponding decode / valueOf methods.

Trims the input String before attempting to parse the number. Supports numbers in hex format (with leading "0x", "0X" or "#") as well.

参数:
text - the text to convert
targetClass - the target class to parse into
返回:
the parsed number
抛出:
IllegalArgumentException - if the target class is not supported (i.e. not a standard Number subclass as included in the JDK)
另请参见:
Byte.decode(java.lang.String), Short.decode(java.lang.String), Integer.decode(java.lang.String), Long.decode(java.lang.String), decodeBigInteger(String), Float.valueOf(java.lang.String), Double.valueOf(java.lang.String), BigDecimal.BigDecimal(String)

parseNumber

public static <T extends Number> T parseNumber(String text,
                                               Class<T> targetClass,
                                               NumberFormat numberFormat)
Parse the given text into a number instance of the given target class, using the given NumberFormat. Trims the input String before attempting to parse the number.

参数:
text - the text to convert
targetClass - the target class to parse into
numberFormat - the NumberFormat to use for parsing (if null, this method falls back to parseNumber(String, Class))
返回:
the parsed number
抛出:
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, java.text.ParsePosition), convertNumberToTargetClass(java.lang.Number, java.lang.Class), parseNumber(String, Class)

isNumber

public static boolean isNumber(String index)


Copyright © 2013-2014. All Rights Reserved.