List of usage examples for java.text DecimalFormatSymbols setMonetaryDecimalSeparator
public void setMonetaryDecimalSeparator(char sep)
From source file:Main.java
public static String safeDoubleToCurrency(Double val) { BigDecimal value = BigDecimal.valueOf(val); DecimalFormat kursIndonesia = (DecimalFormat) DecimalFormat.getCurrencyInstance(); DecimalFormatSymbols formatRp = new DecimalFormatSymbols(); formatRp.setCurrencySymbol(""); formatRp.setMonetaryDecimalSeparator('.'); formatRp.setGroupingSeparator(','); kursIndonesia.setDecimalFormatSymbols(formatRp); kursIndonesia.setParseBigDecimal(true); if (val < 1) kursIndonesia.setMaximumFractionDigits(8); else if (val < 10) kursIndonesia.setMaximumFractionDigits(6); else if (val < 100) kursIndonesia.setMaximumFractionDigits(4); return kursIndonesia.format(value); }