public class

NumberFormatter

extends AbstractNumberFormatter
java.lang.Object
   ↳ org.springframework.format.number.AbstractNumberFormatter
     ↳ org.springframework.format.number.NumberFormatter

Class Overview

A general-purpose Number formatter.

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

Summary

Public Constructors
NumberFormatter()
Create a new NumberFormatter without a pattern.
NumberFormatter(String pattern)
Create a new NumberFormatter with the specified pattern.
Public Methods
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.
[Expand]
Inherited Methods
From class org.springframework.format.number.AbstractNumberFormatter
From class java.lang.Object
From interface org.springframework.format.Parser
From interface org.springframework.format.Printer

Public Constructors

public NumberFormatter ()

Create a new NumberFormatter without a pattern.

public NumberFormatter (String pattern)

Create a new NumberFormatter with the specified pattern.

Parameters
pattern the format pattern

Public Methods

public NumberFormat getNumberFormat (Locale locale)

Obtain a concrete NumberFormat for the specified locale.

Parameters
locale the current locale
Returns
  • the NumberFormat instance (never null)

public void setPattern (String pattern)

Sets the pattern to use to format number values. If not specified, the default DecimalFormat pattern is used.