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)| Constructor and Description |
|---|
CurrencyStyleFormatter() |
| Modifier and Type | Method and Description |
|---|---|
protected NumberFormat |
getNumberFormat(Locale locale)
Obtain a concrete NumberFormat for the specified locale.
|
BigDecimal |
parse(String text,
Locale locale)
Parse a text String to produce a T.
|
void |
setCurrency(Currency currency)
Specify the currency, if known.
|
void |
setFractionDigits(int fractionDigits)
Specify the desired number of fraction digits.
|
void |
setPattern(String pattern)
Sets the pattern to use to format number values.
|
void |
setRoundingMode(RoundingMode roundingMode)
Specify the rounding mode to use for decimal parsing.
|
print, setLenientpublic void setFractionDigits(int fractionDigits)
public void setRoundingMode(RoundingMode roundingMode)
RoundingMode.UNNECESSARY.public void setCurrency(Currency currency)
public void setPattern(String pattern)
DecimalFormat.applyPattern(String)public BigDecimal parse(String text, Locale locale) throws ParseException
Parserparse in interface Parser<Number>parse in class AbstractNumberFormattertext - the text stringlocale - the current user localeParseException - when a parse exception occurs in a java.text parsing libraryprotected NumberFormat getNumberFormat(Locale locale)
AbstractNumberFormattergetNumberFormat in class AbstractNumberFormatterlocale - the current localenull)