Java Currency Code Get getCurrencyDisplay(Object amount)

Here you can find the source of getCurrencyDisplay(Object amount)

Description

get Currency Display

License

LGPL

Declaration

public static String getCurrencyDisplay(Object amount) 

Method Source Code

//package com.java2s;
/*//from www  .  j a  va2s .  co  m
 *   This software is distributed under the terms of the FSF 
 *   Gnu Lesser General Public License (see lgpl.txt). 
 *
 *   This program is distributed WITHOUT ANY WARRANTY. See the
 *   GNU General Public License for more details.
 */

import java.text.NumberFormat;

public class Main {
    public static String getCurrencyDisplay(Object amount) {
        String display = "";
        try {
            if (amount != null && !isEmpty(amount))
                display = NumberFormat.getCurrencyInstance().format(amount);
        } catch (IllegalArgumentException ie) {
        }
        return display;
    }

    public static String getCurrencyDisplay(double amount) {
        return getCurrencyDisplay(new Double(amount));
    }

    /**
     * Checks if a data object is empty. An empty object is either null or an 
     * empty string.
     * 
     * @param data      the data to check
     * @return true if the data object is not empty
     */
    public static boolean isEmpty(Object data) {
        if (data == null || "".equals(data.toString()))
            return true;
        return false;
    }
}

Related

  1. countryCodesForCurrency(String c)
  2. currencyFromCode(String currency)
  3. getAvaiableCurrencySymbols()
  4. getCurrency(final String code)
  5. getCurrencyNationNumber(double num, int dec)
  6. getCurrencyString(long value)
  7. getDefaultCurrency()
  8. getInstance(String currencyCode)