Java Currency Format formatCurrency(String currency)

Here you can find the source of formatCurrency(String currency)

Description

currency fomate

License

Open Source License

Parameter

Parameter Description
currency a parameter

Declaration

public static String formatCurrency(String currency) 

Method Source Code

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

import java.text.NumberFormat;

import java.util.Locale;

public class Main {
    /**//from  w w w  .  j  a  va  2s  .  c  om
     * currency fomate
     * 
     * @param currency
     * @return
     */
    public static String formatCurrency(String currency) {
        if ((null == currency) || "".equals(currency) || "null".equals(currency)) {
            return "";
        }

        NumberFormat usFormat = NumberFormat.getCurrencyInstance(Locale.CHINA);
        try {
            return usFormat.format(Double.parseDouble(currency));
        } catch (Exception e) {
            return "";
        }
    }
}

Related

  1. formatCurrency(Float amt)
  2. formatCurrency(Float f)
  3. formatCurrency(int amount)
  4. formatCurrency(Number currencyValue)
  5. formatCurrency(Object value)
  6. formatCurrencyWithCurrencyUnit(double amt, int fractionDigits)
  7. getCurrencyFormat()
  8. getCurrencyFormat(final Locale locale)
  9. getCurrencyFormatter()