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 {
    /**//from  www . j av  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. formatAmount(float f)
  2. formatFloatValue(float value)
  3. formatFloat(float money)
  4. formatSpeed(float data)
  5. formatSpeed(float data, String format)
  6. formatSpeedValue(float speed)
  7. formatSpeedWithUnit(float speed)