amount Format as ,##0.00 - Java java.text

Java examples for java.text:DecimalFormat

Description

amount Format as ,##0.00

Demo Code


//package com.java2s;
import java.math.BigDecimal;
import java.text.DecimalFormat;

public class Main {
    public static void main(String[] argv) throws Exception {
        BigDecimal inAmount = new BigDecimal("1234");
        System.out.println(amountFormate(inAmount));
    }//from w ww. j a  va2 s  . c  om

    public static String amountFormate(BigDecimal inAmount) {
        String pattern = ",##0.00";
        String str = "";
        if (null != inAmount) {
            DecimalFormat de = new DecimalFormat(pattern);
            str = de.format(inAmount);
        }
        return str;
    }
}

Related Tutorials