List of utility methods to do Number Format Pattern
String | countFormat(int no) Returns a formatted number inclusive counting ending (see #countEnding(int) . return new DecimalFormat().format(no) + countEnding(no); |
DecimalFormat | createDecimalFormat(final String pattern) Creates a new DecimalFormat using comming dot as a separator so local decimal serparators dont matter return createDecimalFormat(pattern, '.'); |
DecimalFormat | CreateDecimalFormat(int numberOfDecimalsDisplayed) Gets the amount of decimals that should be displayed with a DecimalFormat object. if (numberOfDecimalsDisplayed < 1) return new DecimalFormat("#"); String format = "#."; for (int i = 1; i <= numberOfDecimalsDisplayed; i++) format += "#"; return new DecimalFormat(format); |
DecimalFormat | createDecimalFormat(String pattern) create Decimal Format return new DecimalFormat(pattern); |
DecimalFormat | createDecimalFormatter(String pattern) create Decimal Formatter DecimalFormat formatter = (DecimalFormat) NumberFormat.getCurrencyInstance(Locale.US);
formatter.applyPattern(pattern);
return formatter;
|
NumberFormat | createNumberFormat() create Number Format DecimalFormat result = new DecimalFormat(); result.setMaximumFractionDigits(4); return result; |
NumberFormat | createNumberFormat(int cnt) create Number Format StringBuilder sb = new StringBuilder(); sb.append("0"); if (cnt > 0) { sb.append("."); for (int i = 0; i < cnt; i++) { sb.append("0"); return new DecimalFormat(new String(sb)); |
NumberFormat | createOrderVolumeNumberFormat() create Order Volume Number Format return new DecimalFormat("###,###,###,###,##0.00"); |
NumberFormat | createRealFormat() create Real Format NumberFormat format = NumberFormat.getNumberInstance();
format.setMinimumFractionDigits(0);
format.setMaximumFractionDigits(14);
return format;
|
String | expFormatRupiah(Number input, boolean prependRp) exp Format Rupiah if (rupiahFormat == null) { DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(); decimalFormatSymbols.setCurrencySymbol(prependRp ? "Rp " : ""); decimalFormatSymbols.setMonetaryDecimalSeparator(','); decimalFormatSymbols.setGroupingSeparator('.'); rupiahFormat = (DecimalFormat) NumberFormat.getCurrencyInstance(); rupiahFormat.setDecimalFormatSymbols(decimalFormatSymbols); return rupiahFormat.format(input); |