public class CurrencyStyleFormatter extends AbstractNumberFormatter
Delegates to NumberFormat.getCurrencyInstance(Locale).
Configures BigDecimal parsing so there is no loss of precision.
Can apply a specified RoundingMode to parsed values.
AbstractNumberFormatter.setLenient(boolean),
setRoundingMode(java.math.RoundingMode)| Modifier and Type | Field and Description |
|---|---|
private java.util.Currency |
currency |
private int |
fractionDigits |
private java.lang.String |
pattern |
private java.math.RoundingMode |
roundingMode |
| Constructor and Description |
|---|
CurrencyStyleFormatter() |
| Modifier and Type | Method and Description |
|---|---|
protected java.text.NumberFormat |
getNumberFormat(java.util.Locale locale)
Obtain a concrete NumberFormat for the specified locale.
|
java.math.BigDecimal |
parse(java.lang.String text,
java.util.Locale locale)
Parse a text String to produce a T.
|
void |
setCurrency(java.util.Currency currency)
Specify the currency, if known.
|
void |
setFractionDigits(int fractionDigits)
Specify the desired number of fraction digits.
|
void |
setPattern(java.lang.String pattern)
Sets the pattern to use to format number values.
|
void |
setRoundingMode(java.math.RoundingMode roundingMode)
Specify the rounding mode to use for decimal parsing.
|
print, setLenientprivate int fractionDigits
private java.math.RoundingMode roundingMode
private java.util.Currency currency
private java.lang.String pattern
public void setFractionDigits(int fractionDigits)
public void setRoundingMode(java.math.RoundingMode roundingMode)
RoundingMode.UNNECESSARY.public void setCurrency(java.util.Currency currency)
public void setPattern(java.lang.String pattern)
DecimalFormat.applyPattern(String)public java.math.BigDecimal parse(java.lang.String text,
java.util.Locale locale)
throws java.text.ParseException
Parserparse in interface Parser<java.lang.Number>parse in class AbstractNumberFormattertext - the text stringlocale - the current user localejava.text.ParseException - when a parse exception occurs in a java.text parsing libraryprotected java.text.NumberFormat getNumberFormat(java.util.Locale locale)
AbstractNumberFormattergetNumberFormat in class AbstractNumberFormatterlocale - the current localenull)