MoneyFomater

package cc.dfsoft.util;

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

public class MoneyFormatter {
 public static String getDecimalFormat(String str) {
  DecimalFormat fmt = new DecimalFormat("##,###,###,###,##0.00");
  String outStr = null;
  double d;
  try {
   d = Double.parseDouble(str);
   outStr = fmt.format(d);
  } catch (Exception e) {
  }
  return outStr;
 }

 public static String getCurrency(String str) {
  NumberFormat n = NumberFormat.getCurrencyInstance();
  double d;
  String outStr = null;
  try {
   d = Double.parseDouble(str);
   outStr = n.format(d);
  } catch (Exception e) {
   e.printStackTrace();
  }
  return outStr;
 }
}

你可能感兴趣的:(MoneyFomater)