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

StringgetPercentNumber(double num, int scale)
get Percent Number
NumberFormat format = NumberFormat.getPercentInstance();
format.setMinimumFractionDigits(scale);
return format.format(num);
StringgetPercentString(double numerator, double denominator)
get Percent String
if (denominator == 0) {
    return "0.00%";
return FORMAT_PERCENT.format((numerator / denominator) * 100) + "%";
StringgetPercentValue(double value)
Takes a double and turns it into a percent string.
value = Math.floor(value * 100) / 100; 
return NumberFormat.getPercentInstance().format(value);
StringgetPercentWidth(int iColspan, int iMaxTd)
get Percent Width
double dMin = iColspan * 1.0;
double dMax = iMaxTd * 1.0;
double dResult = dMin / dMax;
NumberFormat objNf = NumberFormat.getPercentInstance();
objNf.setMinimumFractionDigits(0);
return objNf.format(dResult);