List of utility methods to do Number Format Pattern
String | getFormatedPrice(BigDecimal price) get Formated Price String formatedPrice = PRICE_FORMATTER.format(price); if (currency != null && currency.length() > 0) formatedPrice += " (" + currency + ")"; return formatedPrice; |
String | getFormattedInteger(int n) Utility method to get an ineteger as a formatted string. df.setGroupingUsed(true); df.setGroupingSize(3); dfs.setGroupingSeparator('.'); df.setDecimalFormatSymbols(dfs); return df.format(n); |
String | getFormattedNumber(int number) get Formatted Number return formatter.format(number);
|
Number | getFormattedNumber(NumberFormat numberFormat, String fieldValue, Class> valueClass) Creates a number from a string value if (valueClass.equals(Byte.class)) { return new Byte((numberFormat.parse(fieldValue)).byteValue()); } else if (valueClass.equals(Integer.class)) { return Integer.valueOf((numberFormat.parse(fieldValue)).intValue()); } else if (valueClass.equals(Long.class)) { return new Long((numberFormat.parse(fieldValue)).longValue()); } else if (valueClass.equals(Short.class)) { return new Short((numberFormat.parse(fieldValue)).shortValue()); ... |
String | getFormattedNumber(String input) get Formatted Number if (df == null) { return input; try { return df.format(Double.parseDouble(input)); } catch (NumberFormatException nfe) { return input; |
String | getFormattedQuantity(String qty, int len, String pad) Method getFormattedQuantity. String result = replaceNullObjectwithBlank(qty); char decimalseparator = java.text.DecimalFormatSymbols.getInstance().getDecimalSeparator(); char thousandseparator = java.text.DecimalFormatSymbols.getInstance().getGroupingSeparator(); if (result.equals("")) { result = "0"; result = result.trim(); if (result.length() > 0) { ... |
String | getFormattedString4Digits(String number, String pattern) get Formatted String Digits double amount = 0; try { amount = Double.parseDouble(number); DecimalFormat formatter = new DecimalFormat(pattern); return formatter.format(amount); } catch (Exception ex) { return number; |
DecimalFormat | getFormatter() get Formatter return FORMATTER.get();
|
DecimalFormat | getFormatter() get Formatter if (formatter == null) { DecimalFormat lFormatter = new DecimalFormat("#,###.###"); DecimalFormatSymbols smb = new DecimalFormatSymbols(); smb.setGroupingSeparator(' '); lFormatter.setDecimalFormatSymbols(smb); formatter = lFormatter; return formatter; ... |
DecimalFormat | getFormatter(int precision) get Formatter String cacheFormat = cache.get(Integer.valueOf(precision)); if (cacheFormat != null) return new DecimalFormat(cacheFormat); StringBuilder format = new StringBuilder("##0."); for (int i = 0; i < precision; i++) format.append(0); DecimalFormat df = new DecimalFormat(format.toString()); cache.put(Integer.valueOf(precision), format.toString()); ... |