Java tutorial
//package com.java2s; import java.text.NumberFormat; public class Main { public static String numFormat(int len, int num) { NumberFormat formatter = NumberFormat.getNumberInstance(); formatter.setMinimumIntegerDigits(len); formatter.setGroupingUsed(false); String numStr = formatter.format(num); return numStr; } }