Class AbstractNumberFormatter
- java.lang.Object
- org.springframework.format.number.AbstractNumberFormatter
- Direct Known Subclasses:
CurrencyStyleFormatter,NumberStyleFormatter,PercentStyleFormatter
public abstract class AbstractNumberFormatter extends Object implements Formatter<Number>
Abstract formatter for Numbers, providing agetNumberFormat(java.util.Locale)template method.- Since:
- 3.0
- Author:
- Juergen Hoeller, Keith Donald
Constructor Summary
Constructors Constructor Description AbstractNumberFormatter()
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract NumberFormatgetNumberFormat(Locale locale)Obtain a concrete NumberFormat for the specified locale.Numberparse(String text, Locale locale)Parse a text String to produce a T.Stringprint(Number number, Locale locale)Print the object of type T for display.voidsetLenient(boolean lenient)Specify whether or not parsing is to be lenient.
Constructor Detail
AbstractNumberFormatter
public AbstractNumberFormatter()
Method Detail
setLenient
public void setLenient(boolean lenient)
Specify whether or not 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.
print
public String print(Number number, Locale locale)
Description copied from interface:PrinterPrint the object of type T for display.
parse
public Number parse(String text, Locale locale) throws ParseException
Description copied from interface:ParserParse a text String to produce a T.- Specified by:
parsein interfaceParser<Number>- Parameters:
text- the text stringlocale- the current user locale- Returns:
- an instance of T
- Throws:
ParseException- when a parse exception occurs in a java.text parsing library
getNumberFormat
protected abstract NumberFormat getNumberFormat(Locale locale)
Obtain a concrete NumberFormat for the specified locale.- Parameters:
locale- the current locale- Returns:
- the NumberFormat instance (never
null)