Java Currency Format currency(double amount, String language, String country)

Here you can find the source of currency(double amount, String language, String country)

Description

Format a currency amount in a given locale.

License

Apache License

Declaration

public static String currency(double amount, String language, String country) 

Method Source Code

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

import java.text.NumberFormat;

import java.util.Locale;

public class Main {
    /**/*from   w ww  .  j  a v  a  2  s.co  m*/
     * Format a currency amount in a given locale.
     */
    public static String currency(double amount, Locale locale) {
        NumberFormat nf = NumberFormat.getCurrencyInstance(locale);
        return nf.format(amount);
    }

    /**
     * Format a currency amount in a given locale.
     */
    public static String currency(double amount, String language, String country) {
        Locale locale = null;
        if (language == null || country == null) {
            locale = Locale.getDefault();
        } else {
            locale = new Locale(language, country);
        }
        return currency(amount, locale);
    }
}

Related

  1. currency(double amount, String language, String country)
  2. currency(double value, NumberFormat nformat)
  3. currencyFormat()
  4. format2CurrencyWithComma(double amt)
  5. formatAsCurrency(BigDecimal nAmount)