ObjectConverterByteConverter, DoubleConverter, FloatConverter, IntegerConverter, LongConverter, NaturalNumberConverter, NumberFormatConverter, ShortConverter, YearNameConverterpublic abstract class NumberConverter extends java.lang.Object implements ObjectConverter
| Modifier and Type | Field | Description |
|---|---|---|
static ConverterContext |
CONTEXT_FRACTION_NUMBER |
| Constructor | Description |
|---|---|
NumberConverter() |
Creates a number converter with no NumberFormat.
|
NumberConverter(java.text.NumberFormat format) |
Creates the number converter with a specified NumberFormat.
|
| Modifier and Type | Method | Description |
|---|---|---|
protected java.text.NumberFormat |
getDefaultNumberFormat() |
Gets the NumberFormat for Locale.US.
|
protected java.text.NumberFormat |
getNumberFormat() |
Gets the NumberFormat.
|
boolean |
isAvoidNegativeZero() |
Gets the flag indicating if negative zero should be avoided.
|
static boolean |
isGroupingUsed() |
Gets flag if the grouping is used for the format.
|
protected java.lang.Number |
parseNumber(java.lang.String string) |
Parse the string as number.
|
void |
setAvoidNegativeZero(boolean avoidNegativeZero) |
Sets the flag indicating if negative zero should be avoided.
|
void |
setCurrency(java.util.Currency currency) |
Set the currency of this converter.
|
void |
setFractionDigits(int minDigits,
int maxDigits) |
Set the fraction digits of this converter.
|
static void |
setGroupingUsed(boolean groupingUsed) |
Sets if the grouping will be used for the NumberFormat.
|
void |
setIntegerDigits(int minDigits,
int maxDigits) |
Set the integer digits of this converter.
|
void |
setNumberFormat(java.text.NumberFormat numberFormat) |
|
void |
setRoundingMode(java.math.RoundingMode mode) |
Set the rounding mode of this converter.
|
boolean |
supportToString(java.lang.Object object,
ConverterContext context) |
If it supports toString method.
|
java.lang.String |
toString(java.lang.Object object,
ConverterContext context) |
Converts from object to String based on current locale.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitfromString, supportFromStringpublic static final ConverterContext CONTEXT_FRACTION_NUMBER
public NumberConverter()
public NumberConverter(java.text.NumberFormat format)
format - the number format.public java.lang.String toString(java.lang.Object object,
ConverterContext context)
ObjectConvertertoString in interface ObjectConverterobject - object to be convertedcontext - converter context to be usedpublic boolean supportToString(java.lang.Object object,
ConverterContext context)
ObjectConvertersupportToString in interface ObjectConverterobject - object to be convertedcontext - converter context to be usedpublic void setNumberFormat(java.text.NumberFormat numberFormat)
protected java.text.NumberFormat getNumberFormat()
protected java.text.NumberFormat getDefaultNumberFormat()
protected java.lang.Number parseNumber(java.lang.String string)
string - the stringpublic static boolean isGroupingUsed()
public static void setGroupingUsed(boolean groupingUsed)
groupingUsed - true or false.public void setFractionDigits(int minDigits,
int maxDigits)
minDigits - minimum fraction digitsmaxDigits - maximum fraction digitspublic void setCurrency(java.util.Currency currency)
currency - currencypublic void setIntegerDigits(int minDigits,
int maxDigits)
minDigits - minimum integer digitsmaxDigits - maximum integer digitspublic void setRoundingMode(java.math.RoundingMode mode)
mode - rounding modepublic boolean isAvoidNegativeZero()
setAvoidNegativeZero(boolean)public void setAvoidNegativeZero(boolean avoidNegativeZero)
avoidNegativeZero - the flag