Java Utililty Methods Currency Format

List of utility methods to do Currency Format

Description

The list of methods to do Currency Format are organized into topic(s).

Method

StringformatCurrency(int amount)
Returns the amount as a formatted currency amount for the locale.
NumberFormat nf = NumberFormat.getCurrencyInstance();
return nf.format(((double) amount) / 100);
StringformatCurrency(Number currencyValue)
Method formatCurrency.
if (currencyValue == null)
    return "";
if (currencyValue.doubleValue() == currencyValue.longValue())
    return "" + currencyValue.longValue();
else {
    NumberFormat nf = NumberFormat.getInstance();
    nf.setMaximumFractionDigits(2);
    nf.setMinimumFractionDigits(2);
...
StringformatCurrency(Object value)
format Currency
NumberFormat m_currencyformat = NumberFormat.getCurrencyInstance();
return m_currencyformat.format(((Number) value).doubleValue());
StringformatCurrency(String currency)
currency fomate
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 "";
...
StringformatCurrencyWithCurrencyUnit(double amt, int fractionDigits)
format Currency With Currency Unit
NumberFormat nf = getCurrencyFormat(fractionDigits);
String currAmt = nf.format(amt);
String symbol = (nf instanceof DecimalFormat)
        ? ((DecimalFormat) nf).getDecimalFormatSymbols().getCurrencySymbol()
        : "";
if (symbol.length() == 1) {
    currAmt = currAmt + " " + nf.getCurrency();
return currAmt;
NumberFormatgetCurrencyFormat()
get Currency Format
return getCurrencyFormat(2);
NumberFormatgetCurrencyFormat(final Locale locale)
get Currency Format
return getNumberFraction2Format(locale);
NumberFormatgetCurrencyFormatter()
get Currency Formatter
return currencyFormatterTl.get();
doubleparseCurrency(String currency)
Returns the currency string as a double value
NumberFormat nf = NumberFormat.getCurrencyInstance();
return nf.parse(currency).doubleValue();
BigDecimalremoveTrailingZeroes(BigDecimal value, boolean isCurrency)
Convert BigDecimal to currency or quantity.
if (value == null) {
    return null;
DecimalFormat df;
if (isCurrency) {
    df = new DecimalFormat("0.00####");
} else {
    df = new DecimalFormat("0.######");
...