format Float Amount in #0.## format - Android java.lang

Android examples for java.lang:Double

Description

format Float Amount in #0.## format

Demo Code

import android.util.Log;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{

    public static String formatFloatAmount(float amount) {
        DecimalFormat df = new DecimalFormat("#0.##");
        return df.format(amount);
    }//ww w .  java 2 s  .  c  o m

}

Related Tutorials