java.lang.Object | ||
↳ | org.apache.commons.beanutils.converters.AbstractConverter | |
↳ | org.apache.commons.beanutils.converters.NumberConverter |
Known Direct Subclasses |
Converter
implementaion that handles conversion
to and from java.lang.Number objects.
This implementation handles conversion for the following
java.lang.Number
types.
java.lang.Byte
java.lang.Short
java.lang.Integer
java.lang.Long
java.lang.Float
java.lang.Double
java.math.BigDecimal
java.math.BigInteger
setUseLocaleFormat(true)
setLocale(Locale)
setPattern(String)
setPattern(String)
setLocale(Locale)
toNumber(String)
method is used to convert
from String to Number and the Number's
toString()
method used to convert from
Number to String.
N.B.Patterns can only be specified used the standard
pattern characters and NOT in localized form (see java.text.SimpleDateFormat
).
For example to cater for number styles used in Germany such as 0.000,00
the pattern
is specified in the normal form 0,000.00
and the locale set to Locale.GERMANY
.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Construct a java.lang.Number Converter
that throws a
ConversionException if a error occurs. | |||||||||||
Construct a
java.lang.Number Converter that returns
a default value if an error occurs. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Return the Locale for the Converter
(or
null if none specified). | |||||||||||
Return the number format pattern used to convert
Numbers to/from a
java.lang.String
(or null if none specified). | |||||||||||
Return whether decimals are allowed in the number.
| |||||||||||
Set the Locale for the Converter.
| |||||||||||
Set a number format pattern to use to convert
Numbers to/from a
java.lang.String . | |||||||||||
Set whether a format should be used to convert
the Number.
| |||||||||||
Provide a String representation of this number converter.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Convert an input Number object into a String.
| |||||||||||
Convert the input object into a Number object of the
specified type.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.apache.commons.beanutils.converters.AbstractConverter
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
org.apache.commons.beanutils.Converter
|
Construct a java.lang.Number Converter
that throws a ConversionException
if a error occurs.
allowDecimals | Indicates whether decimals are allowed |
---|
Construct a java.lang.Number
Converter that returns
a default value if an error occurs.
allowDecimals | Indicates whether decimals are allowed |
---|---|
defaultValue | The default value to be returned |
Return the Locale for the Converter
(or null
if none specified).
Return the number format pattern used to convert
Numbers to/from a java.lang.String
(or null
if none specified).
See java.text.SimpleDateFormat
for details
of how to specify the pattern.
Return whether decimals are allowed in the number.
Set the Locale for the Converter.
locale | The locale to use for conversion |
---|
Set a number format pattern to use to convert
Numbers to/from a java.lang.String
.
See java.text.SimpleDateFormat
for details
of how to specify the pattern.
pattern | The format pattern. |
---|
Set whether a format should be used to convert the Number.
useLocaleFormat | true if a number format
should be used.
|
---|
Provide a String representation of this number converter.
Convert an input Number object into a String.
value | The input value to be converted |
---|
Throwable | if an error occurs converting to a String |
---|
Convert the input object into a Number object of the specified type.
targetType | Data type to which this value should be converted. |
---|---|
value | The input value to be converted. |
Throwable | if an error occurs converting to the specified type |
---|