Java Number Format Pattern formatDollar(Object obj)

Here you can find the source of formatDollar(Object obj)

Description

format Dollar

License

Apache License

Declaration

public static String formatDollar(Object obj) 

Method Source Code


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

import java.text.DecimalFormat;

import java.math.BigDecimal;

public class Main {
    public static String formatDollar(Object obj) {
        // null gets converted to empty string
        if (obj == null) {
            return "";
        }/* w  w  w.j a v  a  2  s .co m*/
        BigDecimal bd = (BigDecimal) obj;
        try {
            DecimalFormat intFormat = new DecimalFormat("$###,###,###,##0.00");
            return intFormat.format(bd);
        } catch (Exception e) {
            return "bad Dollar Amount in FormatUtils:" + obj.toString() + " Error:" + e.getMessage();
        }
    }
}

Related

  1. formatBytes(long bytes)
  2. formatBytes(long bytes)
  3. formatBytes(long numBytes)
  4. formatDashboardNumber(Number amount)
  5. formatDisplay(String displayString)
  6. formatDollarTd(Object obj)
  7. formatFileLength(long length)
  8. formatGopNumber(Number gop)
  9. formatI18N(Object ob)