I want to format number which I receive from the local database
Example:
10000 to 10.000 or 1000000 to 100.000
My code:
holder.mTextViewHarga.setText("Rp. " + mProdukList.get(position).gethargaProduk());
i have to try this code before but still error:
Locale localeID = new Locale("in", "ID");
NumberFormat formatRupiah = NumberFormat.getCurrencyInstance(localeID);
holder.mTextViewHarga.setText("Rp. " +formatRupiah.format((double) mProdukList.get(position).gethargaProduk()));
Use DecimalFormat()
DecimalFormat df2 = new DecimalFormat( "#,###,###,##0.00" );
double d = 100.2397;
double d1 = new Double(df2.format(d)).doubleValue();
Output - d1 will be 100.24
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With