List of utility methods to do Decimal Format
double | getCorrectionValue(double basicValue, int digit) get Correction Value if (digit < 0) return basicValue; StringBuilder sb = new StringBuilder("#"); if (digit > 0) { sb.append("0."); for (int i = 0; i < digit; i++) { sb.append("0"); DecimalFormat format = new DecimalFormat(sb.toString()); return Double.parseDouble(format.format(basicValue)); |
DecimalFormat | getDecimalFormat() get Decimal Format NumberFormat nf = NumberFormat.getNumberInstance(loc);
return (DecimalFormat) nf;
|
DecimalFormat | getDecimalFormat() get Decimal Format return mDecFmt;
|
DecimalFormat | getDecimalFormat() get Decimal Format return s_decimalFormat.get();
|
DecimalFormat | getDecimalFormat() get Decimal Format if (decimalFormat == null) { decimalFormat = (DecimalFormat) NumberFormat.getInstance(Locale.ENGLISH); decimalFormat.setParseBigDecimal(true); return decimalFormat; |
DecimalFormat | getDecimalFormat(final int decimalPlaces) Gets a decimal format that with the desired number of decimal places. if (decimalPlaces < 0) { throw new IllegalArgumentException("decimalPlaces must be non-negative"); final DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(); decimalFormatSymbols.setDecimalSeparator('.'); final StringBuilder builder = new StringBuilder(); builder.append("#0"); if (decimalPlaces > 0) { ... |
DecimalFormat | getDecimalFormat(int decimalPlaces, Locale locale) get Decimal Format StringBuffer sb = new StringBuffer(); sb.append("#,###,##0."); for (int i = 0; i < decimalPlaces; i++) { sb.append('0'); DecimalFormat df = (DecimalFormat) DecimalFormat.getInstance(locale); df.applyPattern(sb.toString()); return df; ... |
DecimalFormat | getDecimalFormat(int precision) Get Decimal Format for a specific precision if (precision <= 0) { return integerFormat; char[] chars = new char[precision]; Arrays.fill(chars, '0'); String format = MessageFormat.format(formatTemplate, new String(chars)); return new DecimalFormat(format); |
NumberFormat | getDecimalFormat(int precision) Return decimal number format. int absPrecision = Math.abs(precision); NumberFormat numberFormat = decimalFormatCacheMap.get(absPrecision); if (numberFormat == null) { numberFormat = new DecimalFormat("0"); numberFormat.setMinimumFractionDigits(absPrecision); numberFormat.setMaximumFractionDigits(absPrecision); decimalFormatCacheMap.put(absPrecision, numberFormat); return numberFormat; |
DecimalFormat | getDecimalFormat(int precision, String force) Gets decimal format. String s = force + "."; for (int i = 0; i < precision; i++) s += force; return new DecimalFormat(s); |