List of utility methods to do Fraction Format
String | formatNumber(Double number, String pattern) format Number DecimalFormat df = new DecimalFormat(pattern); return df.format(number); |
Double | formatNumber(Double numberToFormat, int decimalPlacement) format Number if (decimalPlacement == 0) { return new Double(Math.round(numberToFormat.floatValue())); NumberFormat numberFormat = NumberFormat.getInstance(); StringBuffer stringBuffer = new StringBuffer(); FieldPosition fieldPosition = new FieldPosition(0); numberFormat.setGroupingUsed(false); numberFormat.setMaximumFractionDigits(decimalPlacement); ... |
String | formatNumber(double paramDouble, int paramInt) format Number return NumberFormat.getNumberInstance().format(round(paramDouble, paramInt));
|
String | formatNumber(double pValue) format Number java.text.DecimalFormat formatDecimal = new java.text.DecimalFormat(",##0.00"); java.text.DecimalFormatSymbols symbols = new java.text.DecimalFormatSymbols(); symbols.setGroupingSeparator(','); symbols.setDecimalSeparator('.'); formatDecimal.setDecimalFormatSymbols(symbols); return formatDecimal.format(pValue).toString(); |
String | formatNumber(double value) Formats a specified numeric (int or real) value. if (value >= 100) { return formatInt(value); } else if (value >= 0.995) { return REAL_FORMAT_1.format(value); } else if (value >= 0.0995) { return REAL_FORMAT_2.format(value); } else if (value >= 0.00995) { return REAL_FORMAT_3.format(value); ... |
String | formatNumber(double value, double epsilon) Formats a number so that it presents a number of significant figures corresponding to a supplied small difference. epsilon = Math.abs(epsilon); double aval = Math.abs(value); int nsf = Math.max(0, (int) Math.round(-Math.log10(epsilon / aval))); if (aval >= 1e6 || aval <= 1e-4) { return formatNumber(value, "0.#E0", nsf); } else if (epsilon >= 0.9) { return Long.toString((long) Math.round(value)); } else { ... |
String | formatNumber(final double number) format Number return formatNumber(number, true);
|
String | formatNumber(Float d, int scalar) format Number float temp = d.floatValue(); return formatNumber(temp, scalar); |
String | formatNumber(float num, String format) format the number DecimalFormat df = new DecimalFormat(format); return df.format(num); |
String | formatNumber(int fractionDigits, double value) format Number if (fractionDigits >= 0 && fractionDigits <= 10) { return nfs.get(fractionDigits).format(value); throw new RuntimeException("Only supports fraction digits between 0 to 10"); |