public abstract class NumberConverter extends Object implements ObjectConverter
| Modifier and Type | Field and Description |
|---|---|
static ConverterContext |
CONTEXT_FRACTION_NUMBER |
| Constructor and Description |
|---|
NumberConverter()
Creates a number converter with no NumberFormat.
|
NumberConverter(NumberFormat format)
Creates the number converter with a specified NumberFormat.
|
| Modifier and Type | Method and Description |
|---|---|
protected NumberFormat |
getDefaultNumberFormat()
Gets the NumberFormat for Locale.US.
|
protected 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 Number |
parseNumber(String string)
Parse the string as number.
|
void |
setAvoidNegativeZero(boolean avoidNegativeZero)
Sets the flag indicating if negative zero should be avoided.
|
void |
setCurrency(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(NumberFormat numberFormat) |
void |
setRoundingMode(RoundingMode mode)
Set the rounding mode of this converter.
|
boolean |
supportToString(Object object,
ConverterContext context)
If it supports toString method.
|
String |
toString(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(NumberFormat format)
format - the number format.public String toString(Object object, ConverterContext context)
ObjectConvertertoString in interface ObjectConverterobject - object to be convertedcontext - converter context to be usedpublic boolean supportToString(Object object, ConverterContext context)
ObjectConvertersupportToString in interface ObjectConverterobject - object to be convertedcontext - converter context to be usedpublic void setNumberFormat(NumberFormat numberFormat)
protected NumberFormat getNumberFormat()
protected NumberFormat getDefaultNumberFormat()
protected Number parseNumber(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(Currency currency)
currency - currencypublic void setIntegerDigits(int minDigits,
int maxDigits)
minDigits - minimum integer digitsmaxDigits - maximum integer digitspublic void setRoundingMode(RoundingMode mode)
mode - rounding modepublic boolean isAvoidNegativeZero()
setAvoidNegativeZero(boolean)public void setAvoidNegativeZero(boolean avoidNegativeZero)
avoidNegativeZero - the flagCopyright © 2017. All rights reserved.