Left padding a String with Zeros

java, padding, string

Solution

If your string contains numbers only, you can make it an integer and then do padding:

String.format("%010d", Integer.parseInt(mystring));

If not I would like to know how it can be done.

Problem

I've seen similar questions here and here. But am not getting how to left pad a String with Zero. input: "129018" output: "0000129018" The total output length should be TEN.

Original source

Related problems