0

Format Currency Rupiah pada Java

Import file:

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;

Format:

DecimalFormat id = (DecimalFormat) DecimalFormat.getCurrencyInstance();
DecimalFormatSymbols rp = new DecimalFormatSymbols();

rp.setCurrencySymbol("Rp");
rp.setMonetaryDecimalSeparator(',');
rp.setGroupingSeparator('.');
id.setDecimalFormatSymbols(rp);

Double harga = 1000,10;
id.format(harga);