List of utility methods to do Percentage Format
String | percentFormat(final double value) percent Format final NumberFormat nf = NumberFormat.getPercentInstance(); nf.setMaximumFractionDigits(2); return nf.format(value); |
String | percentFormat(float value) percent Format return PERCENT_FORMAT.format(value * 100.0f);
|
String | percentFormat(Object object) percent Format if (object == null) { return ""; NumberFormat percent = NumberFormat.getPercentInstance(); percent.setMaximumFractionDigits(2); return percent.format(object); |
String | percentTotal(double value, double total) percent Total if (total <= 0) { return "0%"; final DecimalFormat df = new DecimalFormat("#.00"); double result = (value * 100) / total; if (result > 0.01) { return df.format(result); return "0.00"; |
boolean | roundedPercentageGreaterThan(double left, double right) rounded Percentage Greater Than return (left > right) && !formatPercentage(left).equals(formatPercentage(right));
|
String | toPercent(Double doubleValue) Format in percent value DecimalFormat df = new DecimalFormat("###.##%"); df.setMaximumFractionDigits(2); df.setMinimumFractionDigits(2); String formatDouble = ""; if (doubleValue != null) { formatDouble = df.format(doubleValue); return formatDouble; ... |
String | toPercent(double percent) to Percent return FORMAT_PERCENT.format(percent) + "%"; |
String | toPercent(double value) to Percent return toPercent(value * 100.0, 100.0);
|
String | toPercent(float f) to Percent if (Float.isNaN(f)) { return "0"; DecimalFormat df = new DecimalFormat("0.00"); return df.format(f); |