August 13, 2021

Display currency in Indian rupee format with rupee symbol

By lj007

To display currency in Indian rupee format just copy and paste below code and use this function whenever displaying currency.

public static String formatToCurrency(double amount) {
        Locale locale = new Locale("en","IN");
        DecimalFormat decimalFormat = (DecimalFormat) DecimalFormat.getCurrencyInstance(locale);
        DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance(locale);
        dfs.setCurrencySymbol("\u20B9");
        decimalFormat.setDecimalFormatSymbols(dfs);
        return decimalFormat.format(amount);
    }