Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

String format dynamic padding

807599Mar 28 2007 — edited Mar 28 2007
String.format("%08d", myInt) will return a string 0 padded to a width of 8. But is there a way to have the amount of padding determined from a variable instead of having ot hardcode 8 in there? So if my program determines the padding needs to be X it can just use X in the String.format() method somehow?

I didn't see it in the API, but I may have overlooked it. I'm using Java 1.5

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 25 2007
Added on Mar 28 2007
4 comments
894 views