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

public abstract Class AbstractNumberFormatter

extends Object
implements Formatter<Number>
Class Inheritance
All Implemented Interfaces
org.springframework.format.Formatter, org.springframework.format.Parser, org.springframework.format.Printer
Known Direct Subclasses
org.springframework.format.number.CurrencyStyleFormatter, org.springframework.format.number.NumberStyleFormatter, org.springframework.format.number.PercentStyleFormatter
Imports
java.text.NumberFormat, .ParseException, .ParsePosition, java.util.Locale, org.springframework.format.Formatter

Abstract formatter for Numbers, providing a getNumberFormat(java.util.Locale) template method.
Authors
Juergen Hoeller, Keith Donald
Since
3.0

Field Summary

Modifier and TypeField and Description
private boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected abstract NumberFormat

Returns:

the NumberFormat instance (never null)
getNumberFormat
(Locale
the current locale
locale
)

Obtain a concrete NumberFormat for the specified locale.

public Number
parse(String
the text string
text
,
Locale
the current user locale
locale
)

Implements org.springframework.format.Parser.parse.

Parse a text String to produce a T.

public void
setLenient(boolean lenient)

Specify whether parsing is to be lenient.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

lenientback to summary
private boolean lenient

Constructor Detail

AbstractNumberFormatterback to summary
public AbstractNumberFormatter()

Method Detail

getNumberFormatback to summary
protected abstract NumberFormat getNumberFormat(Locale locale)

Obtain a concrete NumberFormat for the specified locale.

Parameters
locale:Locale

the current locale

Returns:NumberFormat

the NumberFormat instance (never null)

parseback to summary
public Number parse(String text, Locale locale) throws ParseException

Implements org.springframework.format.Parser.parse.

Doc from org.springframework.format.Parser.parse.

Parse a text String to produce a T.

Parameters
text:String

the text string

locale:Locale

the current user locale

Returns:Number

an instance of T

Annotations
@Override
Exceptions
ParseException:
when a parse exception occurs in a java.text parsing library
setLenientback to summary
public void setLenient(boolean lenient)

Specify whether parsing is to be lenient. Default is false.

With lenient parsing, the parser may allow inputs that do not precisely match the format. With strict parsing, inputs must match the format exactly.