public class MonetaryAmountFormatter extends Object implements Formatter<javax.money.MonetaryAmount>
MonetaryAmount
values,
delegating to MonetaryAmountFormat.format(javax.money.MonetaryAmount)
and MonetaryAmountFormat.parse(java.lang.CharSequence)
.getMonetaryAmountFormat(java.util.Locale)
Constructor and Description |
---|
MonetaryAmountFormatter()
Create a locale-driven MonetaryAmountFormatter.
|
MonetaryAmountFormatter(String formatName)
Create a new MonetaryAmountFormatter for the given format name.
|
Modifier and Type | Method and Description |
---|---|
protected javax.money.format.MonetaryAmountFormat |
getMonetaryAmountFormat(Locale locale)
Obtain a MonetaryAmountFormat for the given locale.
|
javax.money.MonetaryAmount |
parse(String text,
Locale locale)
Parse a text String to produce a T.
|
String |
print(javax.money.MonetaryAmount object,
Locale locale)
Print the object of type T for display.
|
void |
setFormatName(String formatName)
Specify the format name, to be resolved by the JSR-354 provider
at runtime.
|
public MonetaryAmountFormatter()
public MonetaryAmountFormatter(String formatName)
formatName
- the format name, to be resolved by the JSR-354
provider at runtimepublic void setFormatName(String formatName)
Default is none, obtaining a MonetaryAmountFormat
based on the current locale.
public String print(javax.money.MonetaryAmount object, Locale locale)
Printer
public javax.money.MonetaryAmount parse(String text, Locale locale)
Parser
protected javax.money.format.MonetaryAmountFormat getMonetaryAmountFormat(Locale locale)
The default implementation simply calls
MonetaryFormats.getAmountFormat(java.util.Locale, java.lang.String...)
with either the configured format name or the given locale.
locale
- the current localenull
)setFormatName(java.lang.String)