You can add leading 0 to your string like this. Define a string that will be the maximum length of the string that you want. In my case i need a string that will be only 9 char long.
String d = "602939";d = "000000000".substring(0, (9-d.length())) + d;System.out.println(d);
Output : 000602939