Android Utililty Methods String Format

List of utility methods to do String Format

Description

The list of methods to do String Format are organized into topic(s).

Method

StringfillZero(String formatString, int length)
Method Format string
return fillString(formatString, length, '0', true);
Stringformat(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())) {
...
StringcenterString(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);
...