Java Percentage Format formatPercent(final long value, final long total)

Here you can find the source of formatPercent(final long value, final long total)

Description

format Percent

License

Open Source License

Declaration

public static String formatPercent(final long value, final long total) 

Method Source Code


//package com.java2s;
import java.text.DecimalFormat;

public class Main {
    private static final DecimalFormat PERCENT_FORMAT = new DecimalFormat("##0.00%");

    public static String formatPercent(final long value, final long total) {
        return formatPercent((double) value / total);
    }/*from  w  w  w  . j a va  2  s  .  c  om*/

    public static String formatPercent(final double percent) {
        return PERCENT_FORMAT.format(percent);
        //return GMath.roundTo(percent * 100, 2) + "%";
    }
}

Related

  1. formatPercent(Double num1, Double num2)
  2. formatPercent(double p_double, int p_decimals)
  3. formatPercent(double percent)
  4. formatPercent(double v)
  5. formatPercent(double v)
  6. formatPercent(float p_num)
  7. formatPercent1dp(double frac)
  8. formatPercentage(double perc)
  9. formatPercentage(Double percentage)