Java DecimalFormat format money

Description

Java DecimalFormat format money

import java.text.DecimalFormat;

public class Main {
    public static void main(String[] argv) throws Exception {
        String str = "123123.123123";
        System.out.println(formatMoney(str));
    }/*from ww  w  .j av a2  s  . com*/

    public static String formatMoney(String str) {

        Double dou = Double.parseDouble(str);
        return new DecimalFormat("###,##0.00").format(dou);

    }
}



PreviousNext

Related