How can I convert numbers to currency format in android

I want to show my numbers in money format and separate digits like the example below:

1000 -----> 1,000

10000 -----> 10,000

100000 -----> 100,000

1000000 -----> 1,000,000

Thanks


Another approach :

NumberFormat format = NumberFormat.getCurrencyInstance();
format.setMaximumFractionDigits(0);
format.setCurrency(Currency.getInstance("EUR"));

format.format(1000000);

This way, it's displaying 1 000 000 € or 1,000,000 €, depending on device currency's display settings


You need to use a number formatter, like so:

NumberFormat formatter = new DecimalFormat("#,###");
double myNumber = 1000000;
String formattedNumber = formatter.format(myNumber);
//formattedNumber is equal to 1,000,000

Hope this helps!


Currency formatter.

    public static String currencyFormat(String amount) {
        DecimalFormat formatter = new DecimalFormat("###,###,##0.00");
        return formatter.format(Double.parseDouble(amount));
    }

double number = 1000000000.0;
String COUNTRY = "US";
String LANGUAGE = "en";
String str = NumberFormat.getCurrencyInstance(new Locale(LANGUAGE, COUNTRY)).format(number);

//str = $1,000,000,000.00