List of utility methods to do Number Format
String | formatPhoneNo(String country, String area, String number, String inline) format Phone No StringBuffer sb = new StringBuffer(); boolean first = true; if (country != null) country = country.trim(); if (area != null) area = area.trim(); if (number != null) number = number.trim(); ... |
String | formatPhoneNumber(String number) format Phone Number if (isEmpty(number)) return ""; String phoneNumber = number.trim(); if (phoneNumber.length() == 11) { StringBuffer buf = new StringBuffer(); buf.append(phoneNumber.substring(0, 1)); buf.append("("); buf.append(phoneNumber.substring(1, 4)); ... |
String | formatPhoneNumber(String phoneNumber) format Phone Number try { String s = phoneNumber.replaceAll("\\(|\\)|:|-|\\.", ""); ; s = s.replaceAll("(\\d{3})(\\d{3})(\\d{4})(\\d{3})*", "($1) $2-$3x$4"); if (s.endsWith("x")) s = s.substring(0, s.length() - 1); return s; } catch (Exception ex) { ... |
String | formatPrintIntegerToString(long number, boolean printCommasP, boolean printSignP, int radix, int mincol, char padchar, char commachar, int commainterval) format Print Integer To String String text = Long.toString(Math.abs(number), radix); String commaed = (printCommasP) ? formatAddCommas(text, commachar, commainterval) : text; String signed = (number < 0) ? "-" + commaed : (printSignP) ? "+" + commaed : commaed; return formatWriteFieldToString(signed, mincol, 1, 0, padchar, true); |
void | formatRowKey(final long number, final int digits, byte[] dest) format Row Key long d = Math.abs(number); for (int ii = digits - 1; ii >= 0; ii--) { dest[ii] = (byte) ((d % 10) + '0'); d /= 10; |
String | formatSafetyNumber(String digits) format Safety Number final int partCount = 12; int partSize = digits.length() / partCount; StringBuilder f = new StringBuilder(digits.length() + partCount); for (int i = 0; i < partCount; i++) { f.append(digits, i * partSize, (i * partSize) + partSize).append(" "); return f.toString(); |
String | formatSheetNumber100(final int sheetNumber) format Sheet Number if (sheetNumber < 10) { return "00" + sheetNumber; } else if (sheetNumber < 100) { return "0" + sheetNumber; } else { return String.valueOf(sheetNumber); |
String | formatSmallerNumber(String prefix, String suffix, long amnt, boolean useDecimals) format Smaller Number switch (Long.toString(amnt).length()) { case 4: prefix += Long.toString(amnt).substring(0, 1) + (useDecimals ? "." + Long.toString(amnt).substring(1, 3) : "") + "K" + suffix; return prefix; case 5: prefix += Long.toString(amnt).substring(0, 2) + (useDecimals ? "." + Long.toString(amnt).substring(2, 4) : "") + "K" + suffix; ... |
String | formatTo2Digit(int number) Used to format number in 2 digits return number < 10 ? "0" + number : Integer.toString(number); |
String | NumberFormat(double str, int max, int min) Number Format NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(max);
nf.setMinimumFractionDigits(min);
return nf.format(str);
|