类 AbstractNumberFormatter
- java.lang.Object
- org.springframework.format.number.AbstractNumberFormatter
public abstract class AbstractNumberFormatter extends Object implements Formatter<Number>
Abstract formatter for Numbers, providing agetNumberFormat(java.util.Locale)template method.- 从以下版本开始:
- 3.0
- 作者:
- Juergen Hoeller, Keith Donald
构造器概要
构造器 构造器 说明 AbstractNumberFormatter()
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 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.
构造器详细资料
AbstractNumberFormatter
public AbstractNumberFormatter()
方法详细资料
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)
从接口复制的说明:PrinterPrint the object of type T for display.
parse
public Number parse(String text, Locale locale) throws ParseException
从接口复制的说明:ParserParse a text String to produce a T.- 指定者:
parse在接口中Parser<Number>- 参数:
text- the text stringlocale- the current user locale- 返回:
- an instance of T
- 抛出:
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.- 参数:
locale- the current locale- 返回:
- the NumberFormat instance (never
null)