padding a string with 0 in java
String.format("%05d", yournumber);
//%05 means length of 5
// 25 becomes 00025
padding a string with 0 in java
String.format("%05d", yournumber);
//%05 means length of 5
// 25 becomes 00025
java string padding
Have a look at org.apache.commons.lang.StringUtils#rightPad(String str, int size, char padChar).
But the algorithm is very simple (pad right up to size chars):
public String pad(String str, int size, char padChar)
{
StringBuilder padded = new StringBuilder(str);
while (padded.length() < size)
{
padded.append(padChar);
}
return padded.toString();
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us