Java Utililty Methods Percentage Format

List of utility methods to do Percentage Format

Description

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

Method

StringformatPercent(double v)
format Percent
return new DecimalFormat("#.####%").format(v);
StringformatPercent(final long value, final long total)
format Percent
return formatPercent((double) value / total);
StringformatPercent(float p_num)
Generate percentage value according with the special number
float tmpF = (float) (((float) ((int) Math.floor(p_num * 100)) / 100));
Locale en = new Locale("en");
DecimalFormat df = (DecimalFormat) DecimalFormat.getInstance(en);
df.applyPattern("0.00");
return df.format(tmpF);
StringformatPercent1dp(double frac)
Format a fraction as a percentage to 1 decimal place.
return formatterPercent1dp.format(frac);
StringformatPercentage(double perc)
Format as a percentage
return percentFormatter.format(perc);
StringformatPercentage(Double percentage)
Formats a Double representing a percentage into a string
if (percentage == null)
    return "";
return formatPercentage(percentage.doubleValue());
StringformatPercentage(double percentage)
Formats a numeric percentage, as a decimal number with at most 2 digits.
return formatNumber(percentage) + "%";
StringformatPercentage(double percentage)
format Percentage
if (percentageFormatter == null) {
    percentageFormatter = new DecimalFormat("#0.0%");
return percentageFormatter.format(percentage);
StringformatPercentage(int enumerator, int denominator)
format Percentage
return PERCENT_FORMAT.format((double) enumerator / (double) denominator);
StringformatTimePercent(long part, long tot)
format Time Percent
final double timeRatio = (((double) part) / tot);
String timePercent = new DecimalFormat("##.##%").format(timeRatio);
return timePercent;