Java Currency Format getCurrencyFormat()

Here you can find the source of getCurrencyFormat()

Description

get Currency Format

License

Apache License

Declaration

public static NumberFormat getCurrencyFormat() 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.NumberFormat;

import java.util.Locale;

public class Main {
    public static NumberFormat getCurrencyFormat() {
        return getCurrencyFormat(2);
    }//  w  ww . jav a 2s.  c  o  m

    public static NumberFormat getCurrencyFormat(int fractionDigits) {
        NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.US);

        if (fractionDigits != 2) {
            nf.setMinimumFractionDigits(fractionDigits);
            nf.setMaximumFractionDigits(fractionDigits);
        }

        return nf;
    }
}

Related

  1. formatCurrency(int amount)
  2. formatCurrency(Number currencyValue)
  3. formatCurrency(Object value)
  4. formatCurrency(String currency)
  5. formatCurrencyWithCurrencyUnit(double amt, int fractionDigits)
  6. getCurrencyFormat(final Locale locale)
  7. getCurrencyFormatter()
  8. parseCurrency(String currency)
  9. removeTrailingZeroes(BigDecimal value, boolean isCurrency)