List of utility methods to do Decimal Format
Integer | addDouble(Integer i, Double d) add Double if (d == null && i == null) { return null; } else if (d == null && i != null) { return i; } else if (d != null && i == null) { return Integer.valueOf(integerFormatter.format(d)); } else { return i + Integer.valueOf(integerFormatter.format(d)); ... |
Double | adjust(Double lng, Double lat, Double distance, Double angle) adjust double dx = distance * 1000 * Math.sin(angle * Math.PI / 180); double dy = distance * 1000 * Math.cos(angle * Math.PI / 180); double lon1 = (dx / Ed(lat) + rad(lng)) * 180 / Math.PI; double lat1 = (dy / Ec(lat) + rad(lat)) * 180 / Math.PI; if (angle == 0 || angle == 180) { return Double.parseDouble(df.format(lat1)); } else { return Double.parseDouble(df.format(lon1)); ... |
Double | adjustDoubleNumber(Double doubleNumber, int maxIntPart, int maxFloatPart) adjust Double Number NumberFormat numberFormat = NumberFormat.getInstance(Locale.getDefault()); numberFormat.setMaximumFractionDigits(maxFloatPart); numberFormat.setMaximumIntegerDigits(maxIntPart); numberFormat.setMinimumFractionDigits(maxFloatPart); try { doubleNumber = numberFormat.parse(numberFormat.format(doubleNumber)).doubleValue(); } catch (ParseException e) { new RuntimeException("The adjustDecimalNumber method haved an exception", e); ... |
String | createMeanRmsString(double values[]) creates a predefined string, that contains useful statistical information. double mean = calcMean(values); double rms = calcRms(values); double meanrms = calcStandardDeviation(values, mean); String outString = "rms=" + formatter.format(rms) + "; mean=" + formatter.format(mean) + "; stddev=" + formatter.format(meanrms); return outString; |
String | decimal2percent(double decimal, int pos) decimalpercent NumberFormat nt = NumberFormat.getPercentInstance();
nt.setMinimumFractionDigits(pos);
return nt.format(decimal);
|
String | decimal2string(BigDecimal arg, Locale loc) decimalstring if (arg == null) return null; return NumberFormat.getInstance(loc).format(arg); |
String | decimalConversation(double amount) decimal Conversation NumberFormat formatter = new DecimalFormat("#0.00"); return formatter.format(amount); |
DecimalFormat | decimalFormat() decimal Format return decimalFormat(false);
|
String | decimalFormat(double d) decimal Format java.text.DecimalFormat DF = new java.text.DecimalFormat("#,##0.00", new DecimalFormatSymbols(Locale.US)); return DF.format(d); |
String | decimalFormat(double no) decimal Format DecimalFormat df = new DecimalFormat("######.##"); String val = df.format(no); int index = val.indexOf("."); if (index == -1) val = val + ".00"; else { if (val.substring(index + 1, val.length()).length() - 1 == 0) val = val + "0"; ... |