Java tutorial
//package com.java2s; import java.util.Locale; public class Main { public static String padWithZerosToMaxIntWidth(int paramInt) { if (paramInt < 0) { throw new IllegalArgumentException("value must be zero or greater"); } return String.format(Locale.US, "%1$10s", new Object[] { Integer.valueOf(paramInt) }).replace(' ', '0'); } }