public class NaturalNumberConverter extends AbstractNumberConverter<java.lang.Number>
ObjectConverter implementation for a positive integer (a.k.a natural number)| Modifier and Type | Field and Description |
|---|---|
static ConverterContext |
CONTEXT
Default ConverterContext for NaturalNumberConverter.
|
CONTEXT_FIXED_1_DIGIT_FRACTION, CONTEXT_FIXED_2_DIGIT_FRACTION, CONTEXT_FIXED_4_DIGIT_FRACTION, PROPERTY_NUMBER_FORMAT| Constructor and Description |
|---|
NaturalNumberConverter() |
NaturalNumberConverter(java.text.NumberFormat format) |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Number |
fromString(java.lang.String string,
ConverterContext context)
Converts the String to a Byte.
|
getNumberFormat, numberFromString, toStringfromString, getObjectConverterManager, toString, toStringConverterpublic static final ConverterContext CONTEXT
public NaturalNumberConverter()
public NaturalNumberConverter(java.text.NumberFormat format)
public java.lang.Number fromString(java.lang.String string,
ConverterContext context)
AbstractNumberConverter.PROPERTY_NUMBER_FORMAT if any. If
not there, it will use AbstractNumberConverter.getNumberFormat() to get the NumberFormat to do the conversion.
Please note, the conversion may involve rounding or truncation. If the String represent a negative number, this method will return 0 which is the smallest natural number.
fromString in interface ObjectConverter<java.lang.Number>fromString in class DefaultObjectConverter<java.lang.Number>string - the string to be converted.context - the context