List of utility methods to do Fraction Format
String | format(Double num) format java.text.DecimalFormat df = new java.text.DecimalFormat("0.00"); return df.format(num); |
String | format(Double num) format String result = ""; try { result = new DecimalFormat(numericFormat).format(num); } catch (Exception e) { return result; |
double | format(double num, int n) Formats a double with an specified number of decimals. long m = (long) Math.pow(10, n); num *= m; long aux = ((long) num); num = (double) ((double) aux / (double) m); return num; |
String | format(double num, String pattern) format DecimalFormat doubleFormat = new DecimalFormat(pattern); String resultStr = doubleFormat.format(num); return resultStr; |
String | format(double number) format DecimalFormat vf = new DecimalFormat("#00.#E0"); String str = vf.format(number); str = str.replace("E0", " "); str = str.replace("E3", "k"); str = str.replace("E6", "M"); str = str.replace("E9", "G"); str = str.replace("E12", "T"); str = str.replace("E-3", "m"); ... |
String | format(double number) format if (number == (int) number) return String.valueOf((int) number); else return String.valueOf(number); |
String | format(double number) format NumberFormat format = NumberFormat.getNumberInstance();
format.setMaximumFractionDigits(2);
format.setMinimumFractionDigits(0);
format.setGroupingUsed(false);
return format.format(number);
|
double | format(double number, int digits) Use this method like this: String formatted = Util.format(1234.67789, 2); formatted ==> "1234.68" return format("" + number, digits); |
String | format(double number, String fmt) format return new DecimalFormat(fmt).format(number); |
String | format(double price) format DecimalFormat formatter = new DecimalFormat("###,###,##0.00"); return formatter.format(price); |