List of utility methods to do Number Format Pattern
String | toDecimalFormat(BigDecimal value) to Decimal Format return value != null ? DECIMAL_FORMAT.format(value) : "$0.00"; |
String | toFormattedNumber(Object value) to Formatted Number if (value == null) { return ""; if (value instanceof Double || value instanceof Float) { return DEFAULT_DECIMAL_FORMATTER.format(value); return value.toString(); |
Number | toNumber(String numString, String numFormatPattern) Converts a String to a Number, using the specified pattern. Number number = null; if (numFormatPattern == null) { numFormatPattern = "######.##"; synchronized (numberFormat) { numberFormat.applyPattern(numFormatPattern); number = numberFormat.parse(numString); return number; |
String | toNumberFormat(String input) to Number Format if (input.indexOf(".") != -1) return NumberFormat.getInstance().format((new java.lang.Double(input)).doubleValue()); else { return NumberFormat.getInstance().format((new java.lang.Long(input)).longValue()); |
String | toString(int[] a, String separator, NumberFormat formatter) to String StringBuffer result = new StringBuffer(); if (formatter != null) { if (a.length > 0) result.append(formatter.format(a[0])); for (int i = 1; i < a.length; i++) result.append(separator).append(formatter.format(a[i])); } else { if (a.length > 0) ... |
String | toStringFormatted(byte[] bytes) Format a byte array with a numbered header. StringBuilder sb = new StringBuilder(); DecimalFormat df = new DecimalFormat("00 | "); if (bytes != null) { int len = bytes.length; for (int i = 0; i < bytes.length; i++) { sb.append("-----"); sb.append("\n|"); ... |
double | unformatAmount(String formattedNumber) unformats a formatted number to be a double again NumberFormat numberFormatter = NumberFormat.getCurrencyInstance(); Number number = null; try { number = numberFormatter.parse(formattedNumber); } catch (ParseException e) { e.printStackTrace(); double unformattedNumber = number.doubleValue(); ... |
BigDecimal | unformatingDecimalNumber(String cadena, Locale locale, int maxIntPart, int maxFloatPart) Translate an String to BigDecimal number. BigDecimal result = null; NumberFormat numberFormat = settingUpValuesOfFormat(locale, maxIntPart, maxFloatPart); if (null != cadena && !"".equals(cadena.trim())) { try { Number number = numberFormat.parse(cadena); result = new BigDecimal(Double.toString(number.doubleValue())); } catch (ParseException e) { return result; |