I want to know how to format currency in Nigeria naira format. e.g. If I calculate mortgage payment and the value is 150,000.00. How can I format it to display #150,000.00
I want to know how to format currency in Nigeria naira format. e.g. If I calculate mortgage payment and the value is 150,000.00. How can I format it to display #150,000.00
Please post detailed error msg to help you better.
I think the problem you have is related to importing classes. when you use different classes you should import them, usually the IDE do that automatically. here I imported
import java.text.NumberFormat;
import java.util.Locale;
As for the solution you should define locale first, language/ country.
the language use ISO 639 codes ,the country use ISO 3166 codes you can get those codes from wikipedia, etc...
import java.text.NumberFormat;
import java.util.Locale;
public class Format{
public static void main(String[] args) {
int value = 15000000;
Locale nigeria = new Locale("en", "NG");
NumberFormat numFormat = NumberFormat.getCurrencyInstance(nigeria);
System.out.println(numFormat.format(value));
}
}
You already have a string of "150,000.00", so you can just prepend your #, as of
String formatted = "#" + yourstring;