|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.joda.money.format.MoneyFormatterBuilder
public final class MoneyFormatterBuilder
Provides the ability to build a formatter for monetary values.
This class is mutable and intended for use by a single thread. A new instance should be created for each use. The formatters produced by the builder are immutable and thread-safe.
Constructor Summary | |
---|---|
MoneyFormatterBuilder()
Constructor, creating a new empty builder. |
Method Summary | |
---|---|
MoneyFormatterBuilder |
append(MoneyFormatter formatter)
Appends the printers and parsers from the specified formatter to this builder. |
MoneyFormatterBuilder |
append(MoneyPrinter printer,
MoneyParser parser)
Appends the specified printer and parser to this builder. |
MoneyFormatterBuilder |
appendAmount()
Appends the amount to the builder using a standard format. |
MoneyFormatterBuilder |
appendAmount(MoneyAmountStyle style)
Appends the amount to the builder using the specified amount style. |
MoneyFormatterBuilder |
appendAmountLocalized()
Appends the amount to the builder using a grouped localized format. |
MoneyFormatterBuilder |
appendCurrencyCode()
Appends the currency code to the builder. |
MoneyFormatterBuilder |
appendCurrencyNumeric3Code()
Appends the currency code to the builder. |
MoneyFormatterBuilder |
appendCurrencyNumericCode()
Appends the currency code to the builder. |
MoneyFormatterBuilder |
appendCurrencySymbolLocalized()
Appends the localized currency symbol to the builder. |
MoneyFormatterBuilder |
appendLiteral(CharSequence literal)
Appends a literal to the builder. |
MoneyFormatter |
toFormatter()
Builds the formatter from the builder using the default locale. |
MoneyFormatter |
toFormatter(Locale locale)
Builds the formatter from the builder setting the locale. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MoneyFormatterBuilder()
Method Detail |
---|
public MoneyFormatterBuilder appendAmount()
The format used is MoneyAmountStyle.ASCII_DECIMAL_POINT_GROUP3_COMMA
.
The amount is the value itself, such as '12.34'.
public MoneyFormatterBuilder appendAmountLocalized()
The format used is MoneyAmountStyle.LOCALIZED_GROUPING
.
The amount is the value itself, such as '12.34'.
public MoneyFormatterBuilder appendAmount(MoneyAmountStyle style)
The amount is the value itself, such as '12.34'.
The amount style allows the formatting of the number to be controlled in detail.
See MoneyAmountStyle
for more details.
style
- the style to use, not null
public MoneyFormatterBuilder appendCurrencyCode()
The currency code is the three letter ISO code, such as 'GBP'.
public MoneyFormatterBuilder appendCurrencyNumeric3Code()
The numeric code is the ISO numeric code, such as '826' and is zero padded to three digits.
public MoneyFormatterBuilder appendCurrencyNumericCode()
The numeric code is the ISO numeric code, such as '826'.
public MoneyFormatterBuilder appendCurrencySymbolLocalized()
The localized currency symbol is the symbol as chosen by the locale of the formatter.
Symbols cannot be parsed.
public MoneyFormatterBuilder appendLiteral(CharSequence literal)
The localized currency symbol is the symbol as chosen by the locale of the formatter.
literal
- the literal to append, null or empty ignored
public MoneyFormatterBuilder append(MoneyFormatter formatter)
If the specified formatter cannot print, then the the output of this builder will be unable to print. If the specified formatter cannot parse, then the output of this builder will be unable to parse.
formatter
- the formatter to append, not null
public MoneyFormatterBuilder append(MoneyPrinter printer, MoneyParser parser)
If null is specified then the formatter will be unable to print/parse.
printer
- the printer to append, null makes the formatter unable to printparser
- the parser to append, null makes the formatter unable to parse
public MoneyFormatter toFormatter()
Once the builder is in the correct state it must be converted to a
MoneyFormatter
to be used. Calling this method does not
change the state of this instance, so it can still be used.
This method uses the default locale within the returned formatter.
It can be changed by calling MoneyFormatter.withLocale(Locale)
.
public MoneyFormatter toFormatter(Locale locale)
Once the builder is in the correct state it must be converted to a
MoneyFormatter
to be used. Calling this method does not
change the state of this instance, so it can still be used.
This method uses the specified locale within the returned formatter.
It can be changed by calling MoneyFormatter.withLocale(Locale)
.
locale
- the initial locale for the formatter, not null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |