List of utility methods to do Fraction Format
String | formatPair(double in, double out) format Pair boolean mega = in >= 1024 * 1024 || out >= 1024 * 1024; if (mega) { in /= 1024 * 1024; out /= 1024 * 1024; } else { in /= 1024; out /= 1024; DecimalFormat fmt; if (in >= 1000 || out >= 1000) fmt = new DecimalFormat("#0"); else if (in >= 100 || out >= 100) fmt = new DecimalFormat("#0.0"); else fmt = new DecimalFormat("#0.00"); return fmt.format(in) + THINSP + fmt.format(out) + " " + (mega ? 'M' : 'K'); |
String | formatPotencia(float potencia) format Potencia DecimalFormat df = new DecimalFormat(PATRON_POTENCIA); return df.format(potencia); |
String | formatPowerFloat(float averageRfTickSent) format Power Float return FLOAT_NF.format(averageRfTickSent);
|
String | formatPrice(Double price) Formats a Double representing a price into a string if (price == null) return ""; return formatPrice(price.doubleValue()); |
String | formatQuantity(Double quantity) Formats an Double representing a quantity into a string if (quantity == null) return ""; else return formatQuantity(quantity.doubleValue()); |
String | formatRate(double events, double time, String event) Renders a human readable event rate esitmation. StringBuffer buff = new StringBuffer(); NumberFormat format = new DecimalFormat("#.##"); if (events > time) { buff.append(format.format(events / time) + " " + event + "s / 1s on average"); } else { double interval = time / events; int d = (int) (interval / (24 * 3600)); interval -= d * 24 * 3600; ... |
String | formatSimpleDecimal(double d) returns string from double formatted to DecimalFormat("###.##") return simpleFormat.format(d);
|
String | formatSpeed(float speed) Format a floating point to a String with a 1 digit fraction. NumberFormat formatter = NumberFormat.getInstance(); if (speed < 1) { formatter.setMaximumFractionDigits(2); formatter.setMinimumFractionDigits(2); } else { formatter.setMaximumFractionDigits(1); formatter.setMinimumFractionDigits(1); String format = formatter.format(speed); return format; |
String | formatted_string(double number) formattestring double absnumber = Math.abs(number); if (absnumber >= 1000.0 || absnumber < 0.01) { DecimalFormat expformat = new DecimalFormat("0.00E0"); return expformat.format(number); } else { if (absnumber >= 100.0) { DecimalFormat tempformat = new DecimalFormat("000.0"); return tempformat.format(number); ... |
String | formatToEightPlaces(double pValue) format To Eight Places DecimalFormat df = new DecimalFormat("#,###,###,##0.00000000"); return df.format(pValue); |