public static class ParameterConverters.NumberConverter extends ParameterConverters.AbstractParameterConverter<Number>
Converts values to numbers, supporting any subclass of Number
(including generic Number type), and it unboxed counterpart, using a
NumberFormat to parse to a Number and to convert it to a
specific number type:
Number.byteValue()Number.shortValue()Number.intValue()Number.floatValue()Number.longValue()Number.doubleValue()BigInteger.valueOf(long)BigDecimal.valueOf(double)NumberFormat#getInstance(Locale.ENGLISH).
The localized instance NumberFormat.getInstance(Locale) can be
used to convert numbers in specific locales.
| Constructor and Description |
|---|
NumberConverter() |
NumberConverter(NumberFormat numberFormat) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
accept(Type type) |
Number |
convertValue(String value,
Type type) |
public NumberConverter()
public NumberConverter(NumberFormat numberFormat)
public boolean accept(Type type)
accept in interface ParameterConverters.ParameterConverter<Number>accept in class ParameterConverters.AbstractParameterConverter<Number>Copyright © 2003–2019. All rights reserved.