List of utility methods to do String Format
String | fillZero(String formatString, int length) Method Format string return fillString(formatString, length, '0', true); |
String | format(String message, Object[] params) Apply printf() like formatting to a string. int currentParamNumber = 0; StringBuffer formattedMessage = new StringBuffer(); for (int i = 0; i < message.length(); i++) { if (message.charAt(i) == '%') { if (currentParamNumber >= params.length) { formattedMessage.append("?missing data?"); } else if ((params[currentParamNumber] instanceof Number) && (i + 1 < message.length())) { ... |
String | centerString(String input, int size) Center the input string into a new string that is of the indicated size if (input.length() > size) { return input; char[] spaces = new char[size + 1]; for (int idx = 0; idx < spaces.length - 1; idx++) { spaces[idx] = ' '; String strEmpty = new String(spaces); ... |