Java Number Format Pattern expFormatRupiah(Number input, boolean prependRp)

Here you can find the source of expFormatRupiah(Number input, boolean prependRp)

Description

exp Format Rupiah

License

Open Source License

Declaration

public static String expFormatRupiah(Number input, boolean prependRp) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    private static DecimalFormat rupiahFormat;

    public static String expFormatRupiah(Number input, boolean prependRp) {
        if (rupiahFormat == null) {
            DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols();
            decimalFormatSymbols.setCurrencySymbol(prependRp ? "Rp " : "");
            decimalFormatSymbols.setMonetaryDecimalSeparator(',');
            decimalFormatSymbols.setGroupingSeparator('.');

            rupiahFormat = (DecimalFormat) NumberFormat.getCurrencyInstance();
            rupiahFormat.setDecimalFormatSymbols(decimalFormatSymbols);
        }/*w w  w  .j  a  va 2s .  c om*/

        return rupiahFormat.format(input);
    }
}

Related

  1. createDecimalFormatter(String pattern)
  2. createNumberFormat()
  3. createNumberFormat(int cnt)
  4. createOrderVolumeNumberFormat()
  5. createRealFormat()
  6. format(final long l)
  7. format(final long value, final long divider, final String unit)
  8. format(Integer num)
  9. format(long bytes)