Java Currency Formatter

  • + 0 comments

    // Write your code here. DecimalFormat dfc = new DecimalFormat("\u00A4#,##0.00"); DecimalFormatSymbols df=new DecimalFormatSymbols(); df.setCurrencySymbol("Rs."); dfc.setDecimalFormatSymbols(df);

        String us=NumberFormat.getCurrencyInstance(Locale.US).format(payment);
        String china=NumberFormat.getCurrencyInstance(Locale.CHINA).format(payment);
        String france=NumberFormat.getCurrencyInstance(Locale.FRANCE).format(payment);
    
    
        System.out.println("US: " + us);
        System.out.println("India: " + dfc.format(payment));
        System.out.println("China: " + china);
        System.out.println("France: " + france);