Greg
Greg

Reputation: 1710

Format currency in Indian Numbering Format without symbol in java

I already tried some stuff but without success. Is there no simple decimal format for this ?

The first solution does the trick but i do not want to have the symbol

Format format = com.ibm.icu.text.NumberFormat.getCurrencyInstance(new Locale("en", "in"));
        System.out.println(format.format(new BigDecimal("1000000")));

The second solution with decimal format gives me trouble when there are numbers after the separator.

DecimalFormatSymbols symbols5 = new DecimalFormatSymbols();
symbols5.setDecimalSeparator('.');
symbols5.setGroupingSeparator(',');
NumberFormat goodNumberFormat5 = new DecimalFormat("##,##,##1", symbols5);
System.out.println("************");
System.out.println("10,00,000.00");
System.out.println("************");
System.out.println(goodNumberFormat5.format(new BigDecimal(1000000)));
System.out.println(goodNumberFormat5.format(new BigDecimal(1000000.00)));
System.out.println();

The output of this is :

? 10,00,000.00
************
10,00,000.00
************
1,00,00,001
1,00,00,001

How could i fix this ?

The excepted output should be 10,00,000.00

Upvotes: 0

Views: 2124

Answers (1)

Greg
Greg

Reputation: 1710

With a bit of help from RC i found this solution.

    Format format = com.ibm.icu.text.NumberFormat.getCurrencyInstance(new Locale("en", "in"));
    String str = format.format(1000000);
    String strWithoutSymbol = "";
    strWithoutSymbol = str.substring(1,str.length());
    System.out.println(strWithoutSymbol);

Upvotes: 3

Related Questions