Top Description Fields Constructors Methods
org.springframework.format.number

public Class NumberStyleFormatter

extends AbstractNumberFormatter
Class Inheritance
Imports
java.text.DecimalFormat, .NumberFormat, java.util.Locale, org.springframework.lang.Nullable

A general-purpose number formatter using NumberFormat's number style.

Delegates to java.text.NumberFormat#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.

Authors
Keith Donald, Juergen Hoeller
Since
4.2
See Also
setPattern, setLenient

Field Summary

Modifier and TypeField and Description
private String

Constructor Summary

AccessConstructor and Description
public
NumberStyleFormatter()

Create a new NumberStyleFormatter without a pattern.

public
NumberStyleFormatter(String
the format pattern
pattern
)

Create a new NumberStyleFormatter with the specified pattern.

Method Summary

Modifier and TypeMethod and Description
public NumberFormat
getNumberFormat(Locale
the current locale
locale
)

Implements abstract org.springframework.format.number.AbstractNumberFormatter.getNumberFormat.

Obtain a concrete NumberFormat for the specified locale.

public void
setPattern(String pattern)

Specify the pattern to use to format number values.

Inherited from org.springframework.format.number.AbstractNumberFormatter:
parseprintsetLenient

Field Detail

patternback to summary
private String pattern
Annotations
@Nullable

Constructor Detail

NumberStyleFormatterback to summary
public NumberStyleFormatter()

Create a new NumberStyleFormatter without a pattern.

NumberStyleFormatterback to summary
public NumberStyleFormatter(String pattern)

Create a new NumberStyleFormatter with the specified pattern.

Parameters
pattern:String

the format pattern

See Also
setPattern

Method Detail

getNumberFormatback to summary
public NumberFormat getNumberFormat(Locale locale)

Implements abstract org.springframework.format.number.AbstractNumberFormatter.getNumberFormat.

Doc from org.springframework.format.number.AbstractNumberFormatter.getNumberFormat.

Obtain a concrete NumberFormat for the specified locale.

Parameters
locale:Locale

the current locale

Returns:NumberFormat

the NumberFormat instance (never null)

Annotations
@Override
setPatternback to summary
public void setPattern(String pattern)

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

See Also
java.text.DecimalFormat#applyPattern(String)