List of utility methods to do String Format
String | formatNumberWithDecimals(Locale locale, String stringToFormat, int exactNumberOfDecimals) Format String like a number with given decimals return formatNumberWithDecimals(locale, stringToFormat,
exactNumberOfDecimals, exactNumberOfDecimals);
|
String | formatNumberWithDecimals(Locale locale, String stringToFormat, int minimalNumberOfDecimals, int maximumNumberOfDecimals) Format String like a number with given decimals if (stringToFormat == null || stringToFormat.length() == 0) { return null; String result = null; DecimalFormat formatter = new DecimalFormat(); setupFormatter(formatter, locale, minimalNumberOfDecimals, maximumNumberOfDecimals); result = formatter.format(Double.parseDouble(stringToFormat)); ... |
String | formatNumberWithThreeDecimals(Locale locale, String stringToFormat) Format String like a number with three decimals WARNING: Only use this method to present data to the screen return formatNumberWithDecimals(locale, stringToFormat, 3);
|
String | formatNumberWithTwoDecimals(Locale locale, String stringToFormat) Format String like a number with two decimals WARNING: Only use this method to present data to the screen return formatNumberWithDecimals(locale, stringToFormat, 2);
|
String | formatPriceWithThreeDecimals(Locale locale, String stringToFormat) Format String like a price with three decimals WARNING: Only use this method to present data to the screen return formatNumberWithDecimals(locale, stringToFormat, 3);
|
String | formatVolume(Locale locale, String stringToFormat) Format String as a Volume WARNING: Only use this method to present data to the screen if (stringToFormat == null || stringToFormat.length() == 0) { return null; String result = null; DecimalFormat formatter = new DecimalFormat(); formatter.setDecimalFormatSymbols(new DecimalFormatSymbols(locale)); formatter.setGroupingUsed(true); formatter.setGroupingSize(3); ... |
String | formatPriceWithTwoDecimals(Locale locale, String stringToFormat) Format String like a price with two decimals WARNING: Only use this method to present data to the screen if (stringToFormat == null || stringToFormat.length() == 0) { return null; int numberStart = stringToFormat.indexOf(" "); if (numberStart != -1 || (stringToFormat.indexOf("$") > -1 || stringToFormat .indexOf("?") > -1)) { numberStart = Math.max(stringToFormat.indexOf("$"), ... |
String | format(String formatString, Object... args) format Formatter formatter = new Formatter(); String formatedString = formatter.format(formatString, args) .toString(); formatter.close(); return formatedString; |
String | fillSpace(String formatString, int length) Method fill string return fillString(formatString, length, ' ', false); |
String | fillString(String formatString, int length, char fillChar, boolean leftFillFlag) Method fill string if (null == formatString) { formatString = ""; int strLen = formatString.length(); if (strLen >= length) { if (true == leftFillFlag) return formatString.substring(strLen - length, strLen); else ... |