0

I want to group a decimal with different number of grouping by , . But it takes the last grouping only and applies for all grouping. How to format this as expected.

String rupeePattern = "###,##,##,###.##";
double price = 210234.505; //to be formatted to 2,10,234.51
System.out.println("Price:"+ customFormat(rupeePattern, price)); // but get 210,234.51


public static String customFormat(String pattern, double value) {
    DecimalFormat formatter = new DecimalFormat(pattern);
    return formatter.format(value);
}
itsraja
  • 1,640
  • 4
  • 32
  • 48

0 Answers0