List of utility methods to do Fraction Format
String | format(double value, String formatString) format return new DecimalFormat(formatString).format(value); |
double | format(double x, int max, int min) format NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(max); nf.setMinimumFractionDigits(min); try { Number number = nf.parse(nf.format(x)); x = number.doubleValue(); } catch (Exception e) { e.printStackTrace(); ... |
String | format(final double d) Formats a number. final StringBuffer s = new StringBuffer(); return FORMAT_DOUBLE.format(d, s, new java.text.FieldPosition(0)).toString(); |
String | format(final double number) format return DEFAULT_FORMAT.format(number);
|
String | format(final double value) format return DF.format(value);
|
String | format(final double value, final int decimalPlaces) Formats a double value with a given number of decimal places. final DecimalFormat formatter = getDecimalFormat(decimalPlaces); return formatter.format(value); |
String | format(final NumberFormat fmt, final double val) Format the given double value using given formater Note: this method is not thread safe (synchronization must be performed by callers) _fmtBuffer.setLength(0); return format(fmt, _fmtBuffer, val).toString(); |
String | format(float f) format numberFormat.setMaximumFractionDigits(2);
return numberFormat.format(f);
|
String | format(Float f) format return df.format(f);
|
String | format(float num) format df.setMaximumFractionDigits(3);
df.setMinimumFractionDigits(0);
return df.format(num);
|