Java Money Format formatMoney(String money)

Here you can find the source of formatMoney(String money)

Description

format Money

License

Apache License

Declaration

public static String formatMoney(String money) 

Method Source Code

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

import java.text.DecimalFormat;
import java.text.NumberFormat;

public class Main {
    public static String formatMoney(double d) {
        DecimalFormat format = (DecimalFormat) NumberFormat.getPercentInstance();
        format.applyPattern("###########0.00");
        return format.format(d);
    }/*from   w  ww  .  j  ava2s .c  om*/

    public static String formatMoney(String money) {
        if (money == null)
            return "";
        try {
            money = money.trim();
            double d = Double.parseDouble(money);
            return formatMoney(d);
        } catch (Exception e) {
            System.err.println(e);
        }
        return money;
    }
}

Related

  1. formatMoney(double cents, Locale locale)
  2. formatMoney(double dtSource)
  3. formatMoney(double money, int scalar)
  4. formatMoney(int dosh)
  5. formatMoney(Object str)
  6. formatMoneyNoSymbol(int pennies)
  7. formatMoneyShort(int pennies)
  8. formatMoneyVI(String money)
  9. formatOfRead(BigDecimal money)