public abstract class

AbstractNumberFormatter

extends Object
implements Formatter<T>
java.lang.Object
   ↳ org.springframework.format.number.AbstractNumberFormatter
Known Direct Subclasses

Class Overview

Abstract formatter for Numbers, providing a getNumberFormat(java.util.Locale) template method.

Summary

Public Constructors
AbstractNumberFormatter()
Public Methods
Number parse(String text, Locale locale)
Parse a text String to produce a T.
String print(Number number, Locale locale)
void setLenient(boolean lenient)
Specify whether or not parsing is to be lenient.
Protected Methods
abstract NumberFormat getNumberFormat(Locale locale)
Obtain a concrete NumberFormat for the specified locale.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.springframework.format.Parser
From interface org.springframework.format.Printer

Public Constructors

public AbstractNumberFormatter ()

Public Methods

public Number parse (String text, Locale locale)

Parse a text String to produce a T.

Parameters
text the text string
locale the current user locale
Returns
  • an instance of T

public String print (Number number, Locale locale)

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.

Protected Methods

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)