Reputation: 33
public double showinbrl(double amount, double rate) {
double amountinbrl = amount * rate;
NumberFormat brl = NumberFormat.getCurrencyInstance(Locale.BRAZIL);
brl.format(amountinbrl);
return amountinbrl;
}
how to get the locale for the different countries... i cant find locale for brazil..
Upvotes: 0
Views: 1005
Reputation: 23
UPDATING 2023 (KOTLIN):
When I tried to use "Locale.forLanguageTag("pt_BR")" it didn't work for me, it's not formatting correctly and it's showing an unknown character:
So I googled and used the following code and it worked:
val brl = NumberFormat.getCurrencyInstance(Locale("pt", "BR"))
Upvotes: 1
Reputation: 2774
Try this:
NumberFormat brl = NumberFormat.getCurrencyInstance(Locale.forLanguageTag("pt_BR"));
Upvotes: 2