Java Utililty Methods Number Percentage Format

List of utility methods to do Number Percentage Format

Description

The list of methods to do Number Percentage Format are organized into topic(s).

Method

StringgetPercent(Double num)
get Percent
DecimalFormat df = new DecimalFormat("############0.00");
String rtNum = df.format(num * 100);
return rtNum + "%";
StringgetPercent(double percent)
get Percent
return new DecimalFormat("#.##").format(percent);
StringgetPercent(Double value)
get Percent
if (value != null && value > 0) {
    DecimalFormat df = new DecimalFormat();
    df.setMaximumFractionDigits(1);
    df.setMinimumFractionDigits(1);
    if (1 == value) {
        return "100%";
    } else {
        return df.format(value * 100) + "%";
...
StringgetPercent(final long downloadCurrent, final long downloadMax)
get Percent
return (new DecimalFormat("0.00")).format(100.0 * downloadCurrent / downloadMax) + "%";
StringgetPercent(long l1, long l2)
get Percent
final double ratio = l1 / (double) l2;
if (ratio < 0.001d) {
    return "<0.1%";
final DecimalFormat percentFormat = new DecimalFormat("#.#%");
return percentFormat.format(ratio);
StringgetPercent(long val1, long val2)
get Percent
return NF.format((double) val1 / val2);
NumberFormatgetPercentFormatter()
get Percent Formatter
NumberFormat format = DecimalFormat.getPercentInstance();
format.setMinimumFractionDigits(1);
format.setMaximumFractionDigits(1);
return format;
StringgetPercentileWithSuffix(double percentile)
get Percentile With Suffix
String percentileText = new DecimalFormat("0.#########").format(percentile);
return percentileText + getPercentileSuffix(percentileText);
StringgetPercentileWithSuffix(double percentile)
get Percentile With Suffix
String percentileText = new DecimalFormat("0.#########").format(percentile);
return percentileText + getPercentileSuffix(percentileText);
StringgetPercentMemUse()
get Percent Mem Use
return format.format(((float) runtime.totalMemory() / (float) runtime.maxMemory()) * 100);