Android Float Format formatAmount(float f)

Here you can find the source of formatAmount(float f)

Description

12->12.00 or 11111.1 -> 1,111.10

Parameter

Parameter Description
str a parameter

Declaration

public static String formatAmount(float f) 

Method Source Code

//package com.java2s;

import java.text.DecimalFormat;

public class Main {
    /**//w  w w . j a v  a 2  s.  com
     * 12->12.00 or 11111.1 -> 1,111.10
     * 
     * @param str
     * @return
     */
    public static String formatAmount(float f) {
        try {
            DecimalFormat df = new DecimalFormat("###,###.00");
            return df.format(f);
        } catch (Exception e) {
            return "";
        }
    }
}

Related

  1. formatFloatValue(float value)
  2. formatFloat(float money)
  3. formatAmount(float f)
  4. formatSpeed(float data)