Java Number Percentage Format getPercent(long l1, long l2)

Here you can find the source of getPercent(long l1, long l2)

Description

get Percent

License

LGPL

Declaration

public static String getPercent(long l1, long l2) 

Method Source Code

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

import java.text.DecimalFormat;

public class Main {
    public static String getPercent(long l1, long l2) {

        final double ratio = l1 / (double) l2;

        if (ratio < 0.001d) {
            return "<0.1%";
        }/*  w w w . ja  v a 2s .c o m*/

        final DecimalFormat percentFormat = new DecimalFormat("#.#%");
        return percentFormat.format(ratio);
    }
}

Related

  1. getPercent(Double num)
  2. getPercent(double percent)
  3. getPercent(Double value)
  4. getPercent(final long downloadCurrent, final long downloadMax)
  5. getPercent(long val1, long val2)
  6. getPercentFormatter()
  7. getPercentileWithSuffix(double percentile)
  8. getPercentileWithSuffix(double percentile)