List of utility methods to do Number Format Pattern
NumberFormat | getNumberFormatInstanceFor2DecimalDigits() get Number Format Instance For Decimal Digits NumberFormat numberFormatFor2DecimalDigits = NumberFormat.getInstance();
numberFormatFor2DecimalDigits.setMaximumFractionDigits(2);
return numberFormatFor2DecimalDigits;
|
NumberFormat | getNumberFormatter() get Number Formatter if (numberFormatter == null) { DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols(); otherSymbols.setDecimalSeparator('.'); numberFormatter = new DecimalFormat("0.0#######", otherSymbols); return numberFormatter; |
DecimalFormat | getNumberFormatter(final String format) get Number Formatter ThreadLocal<DecimalFormat> threadLocal = decimalFormatters.get(format); if (threadLocal == null) { threadLocal = new ThreadLocal<DecimalFormat>() { @Override protected DecimalFormat initialValue() { return new DecimalFormat(format); }; ... |
NumberFormat | getNumberFraction2Format(final Locale locale) get Number Fraction Format final NumberFormat format = NumberFormat.getNumberInstance(locale); format.setMaximumFractionDigits(2); format.setMinimumFractionDigits(2); return format; |
int | getNumberOfDays(String year, String month) get Number Of Days GregorianCalendar calendar = null; SimpleDateFormat sdf = null; try { int yyyy = Integer.parseInt(year); int mm = Integer.parseInt(month); calendar = new GregorianCalendar(yyyy, mm, 0); sdf = new SimpleDateFormat("dd"); return Integer.parseInt(sdf.format(calendar.getTime())); ... |
int | getNumberStyleAsInt(String style) Checks a string to see if it matches one of the standard NumberFormat style patterns: number, currency, percent, integer, or default. if (style == null || style.length() < 6 || style.length() > 8) { return -1; if (style.equalsIgnoreCase("default")) { return STYLE_NUMBER; if (style.equalsIgnoreCase("number")) { return STYLE_NUMBER; ... |
NumberFormat | getOneFractionDigitNumberFormat() get One Fraction Digit Number Format NumberFormat result = NumberFormat.getInstance();
result.setMaximumFractionDigits(1);
return result;
|
DecimalFormat | getPriceFormat() get Price Format return PRICE_FORMAT;
|
DecimalFormat | getScientificFormatter(int precision) get Scientific Formatter DecimalFormat df = scientificFormatters.get(precision); if (df == null) { StringBuffer format = new StringBuffer("0."); for (int i = 0; i < precision; i++) format.append("#"); format.append("E0"); df = new DecimalFormat(format.toString()); scientificFormatters.put(precision, df); ... |
char | getSeparator(final NumberFormat format) Returns the separator to use between numbers. if (format instanceof DecimalFormat) { final char c = ((DecimalFormat) format).getDecimalFormatSymbols().getDecimalSeparator(); if (c == ',') { return ';'; return ','; |