Based on @Haroldo Macêdo's answer, I created a method in my custom Utils
class such as
/**
* Left padding a string with the given character
*
* @param str The string to be padded
* @param length The total fix length of the string
* @param padChar The pad character
* @return The padded string
*/
public static String padLeft(String str, int length, String padChar) {
String pad = "";
for (int i = 0; i < length; i++) {
pad += padChar;
}
return pad.substring(str.length()) + str;
}
Then call Utils.padLeft(str, 10, "0");