format Amount ###,###,##0.00 - Android java.text

Android examples for java.text:DecimalFormat

Description

format Amount ###,###,##0.00

Demo Code


import java.text.DecimalFormat;
import android.text.Editable;
import android.text.Selection;
import android.text.Spannable;
import android.text.TextWatcher;
import android.widget.EditText;

public class Main{
    //  w w  w  . java 2s  .co  m
    public static String formatAmount(String amount) {
        if (CommonUtils.isEmpty(amount))
            return "0.00";
        // return formatSpecialAmount(amount);
        return formatQueryAmount(amount);
    }
    public static String formatQueryAmount(String amount) {
        DecimalFormat format = new DecimalFormat("###,###,##0.00");
        return format.format(Double.valueOf(amount));
    }
}

Related Tutorials