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