Class CurrencyStyleFormatter
java.lang.Object
org.springframework.format.number.AbstractNumberFormatter
org.springframework.format.number.CurrencyStyleFormatter
A BigDecimal formatter for number values in currency style.
 
Delegates to NumberFormat.getCurrencyInstance(Locale).
 Configures BigDecimal parsing so there is no loss of precision.
 Can apply a specified RoundingMode to parsed values.
- Since:
- 4.2
- Author:
- Keith Donald, Juergen Hoeller
- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected NumberFormatgetNumberFormat(Locale locale) Obtain a concrete NumberFormat for the specified locale.Parse a text String to produce a T.voidsetCurrency(Currency currency) Specify the currency, if known.voidsetFractionDigits(int fractionDigits) Specify the desired number of fraction digits.voidsetPattern(String pattern) Specify the pattern to use to format number values.voidsetRoundingMode(RoundingMode roundingMode) Specify the rounding mode to use for decimal parsing.Methods inherited from class org.springframework.format.number.AbstractNumberFormatterprint, setLenient
- 
Constructor Details- 
CurrencyStyleFormatterpublic CurrencyStyleFormatter()
 
- 
- 
Method Details- 
setFractionDigitspublic void setFractionDigits(int fractionDigits) Specify the desired number of fraction digits. Default is 2.
- 
setRoundingModeSpecify the rounding mode to use for decimal parsing. Default isRoundingMode.UNNECESSARY.
- 
setCurrencySpecify the currency, if known.
- 
setPatternSpecify the pattern to use to format number values. If not specified, the default DecimalFormat pattern is used.- See Also:
 
- 
parseDescription copied from interface:ParserParse a text String to produce a T.- Specified by:
- parsein interface- Parser<Number>
- Overrides:
- parsein class- AbstractNumberFormatter
- Parameters:
- text- the text string
- locale- the current user locale
- Returns:
- an instance of T
- Throws:
- ParseException- when a parse exception occurs in a java.text parsing library
 
- 
getNumberFormatDescription copied from class:AbstractNumberFormatterObtain a concrete NumberFormat for the specified locale.- Specified by:
- getNumberFormatin class- AbstractNumberFormatter
- Parameters:
- locale- the current locale
- Returns:
- the NumberFormat instance (never null)
 
 
-