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

public Class MonetaryAmountFormatter

extends Object
implements Formatter<MonetaryAmount>
Class Inheritance
All Implemented Interfaces
org.springframework.format.Formatter, org.springframework.format.Parser, org.springframework.format.Printer
Imports
java.util.Locale, javax.money.MonetaryAmount, javax.money.format.MonetaryAmountFormat, .MonetaryFormats, org.springframework.format.Formatter, org.springframework.lang.Nullable

Formatter for JSR-354 javax.money.MonetaryAmount values, delegating to javax.money.format.MonetaryAmountFormat#format and javax.money.format.MonetaryAmountFormat#parse.
Author
Juergen Hoeller
Since
4.2
See Also
getMonetaryAmountFormat

Field Summary

Modifier and TypeField and Description
private String

Constructor Summary

AccessConstructor and Description
public
MonetaryAmountFormatter()

Create a locale-driven MonetaryAmountFormatter.

public
MonetaryAmountFormatter(String
the format name, to be resolved by the JSR-354 provider at runtime
formatName
)

Create a new MonetaryAmountFormatter for the given format name.

Method Summary

Modifier and TypeMethod and Description
protected MonetaryAmountFormat

Returns:

the MonetaryAmountFormat (never null)
getMonetaryAmountFormat
(Locale
the current locale
locale
)

Obtain a MonetaryAmountFormat for the given locale.

public MonetaryAmount
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
setFormatName(String formatName)

Specify the format name, to be resolved by the JSR-354 provider at runtime.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

formatNameback to summary
private String formatName
Annotations
@Nullable

Constructor Detail

MonetaryAmountFormatterback to summary
public MonetaryAmountFormatter()

Create a locale-driven MonetaryAmountFormatter.

MonetaryAmountFormatterback to summary
public MonetaryAmountFormatter(String formatName)

Create a new MonetaryAmountFormatter for the given format name.

Parameters
formatName:String

the format name, to be resolved by the JSR-354 provider at runtime

Method Detail

getMonetaryAmountFormatback to summary
protected MonetaryAmountFormat getMonetaryAmountFormat(Locale locale)

Obtain a MonetaryAmountFormat for the given locale.

The default implementation simply calls javax.money.format.MonetaryFormats#getAmountFormat with either the configured format name or the given locale.

Parameters
locale:Locale

the current locale

Returns:MonetaryAmountFormat

the MonetaryAmountFormat (never null)

See Also
setFormatName
parseback to summary
public MonetaryAmount parse(String text, Locale locale)

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:MonetaryAmount

an instance of T

Annotations
@Override
setFormatNameback to summary
public void setFormatName(String formatName)

Specify the format name, to be resolved by the JSR-354 provider at runtime.

Default is none, obtaining a MonetaryAmountFormat based on the current locale.