org.springframework.ui.format.number
Class DecimalFormatter

java.lang.Object
  extended by org.springframework.ui.format.number.AbstractNumberFormatter
      extended by org.springframework.ui.format.number.DecimalFormatter
All Implemented Interfaces:
Formatter<Number>

public final class DecimalFormatter
extends AbstractNumberFormatter

A Number formatter for decimal values.

Delegates to NumberFormat.getInstance(Locale). Configures BigDecimal parsing so there is no loss in precision. Allows configuration over the decimal number pattern. The AbstractNumberFormatter.parse(String, Locale) routine always returns a BigDecimal.

Since:
3.0
Author:
Keith Donald, Juergen Hoeller
See Also:
setPattern(java.lang.String), AbstractNumberFormatter.setLenient(boolean)

Constructor Summary
DecimalFormatter()
           
 
Method Summary
 NumberFormat getNumberFormat(Locale locale)
          Obtain a concrete NumberFormat for the specified locale.
 void setPattern(String pattern)
          Sets the pattern to use to format number values.
 
Methods inherited from class org.springframework.ui.format.number.AbstractNumberFormatter
format, parse, setLenient
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DecimalFormatter

public DecimalFormatter()
Method Detail

setPattern

public void setPattern(String pattern)
Sets the pattern to use to format number values. If not specified, the default DecimalFormat pattern is used.

Parameters:
pattern - the format pattern
See Also:
DecimalFormat.applyPattern(String)

getNumberFormat

public NumberFormat getNumberFormat(Locale locale)
Description copied from class: AbstractNumberFormatter
Obtain a concrete NumberFormat for the specified locale.

Specified by:
getNumberFormat in class AbstractNumberFormatter
Parameters:
locale - the current locale
Returns:
the NumberFormat instance (never null)