Open
Description
The class comment of MonetaryAmountFormat
has two code snippets. Both of them are full of compile errors
MonetaryAmountFormat f = MonetaryFormats.getInstance(loc);
f.setStyle(f.getStyle().toBuilder().setPattern("###.##;(###.##)").build());
- there are no
#setStyle
and#getStyle
methods - there is no
#getInstance
method onMonetaryFormats
, you probably mean#getAmountFormat
Locale[] locales = MonetaryFormats.getAvailableLocales();
MonetaryAmount amount = ...;
MonetaryAmountFormat form;
System.out.println("FORMAT");
for (int i = 0; i < locales.length; ++i) {
if (locales[i].getCountry().length() == 0) {
continue; // Skip language-only locales
}
System.out.print(locales[i].getDisplayName());
form = MonetaryFormats.getInstance(locales[i]);
System.out.print(": " + form.getStyle().getPattern());
String myAmount = form.format(amount);
System.out.print(" -> " + myAmount);
try {
System.out.println(" -> " + form.parse(form.format(myAmount)));
} catch (ParseException e) {}
}
}
- there is no
MonetaryFormats#getAvailableLocales()
, you could useLocale#getAvailableLocales()
but then you should probably also checkMonetaryFormats#isAvailable
- while no a compile error an enhanced for loop over the locales would be nice
- again there is no
#getStyle
method - there is no
#getInstance
method onMonetaryFormats
#parse
does not throwParseException
butMonetaryParseException
- the last } is too much