Java Currency Format formatAsCurrency(final double value)

Here you can find the source of formatAsCurrency(final double value)

Description

format As Currency

License

Open Source License

Declaration

public static String formatAsCurrency(final double value) 

Method Source Code


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

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;

public class Main {
    static DecimalFormat dFormat = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));

    public static String formatAsCurrency(final double value) {
        String str = dFormat.format(value);
        if (str.endsWith(".00")) {
            str = str.substring(0, str.length() - 3);
        }/*from   w  w w  .j ava 2s. co  m*/
        return str;
    }
}

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)
  6. formatAsCurrency(Number amount)
  7. formatAsCurrency(Number value)
  8. formatCurrency(BigDecimal amount)
  9. formatCurrency(BigDecimal bd)