Java Percentage Format toPercent(float f)

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

Description

to Percent

License

Apache License

Declaration

public static String toPercent(float f) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.DecimalFormat;

public class Main {
    public static String toPercent(float f) {
        if (Float.isNaN(f)) {
            return "0";
        }//ww  w . j  av  a 2 s .  co m

        DecimalFormat df = new DecimalFormat("0.00");

        return df.format(f);
    }
}

Related

  1. percentTotal(double value, double total)
  2. roundedPercentageGreaterThan(double left, double right)
  3. toPercent(Double doubleValue)
  4. toPercent(double percent)
  5. toPercent(double value)