Here you can find the source of intToStr(int value, int len)
public static String intToStr(int value, int len)
//package com.java2s; //License from project: Apache License public class Main { public static String intToStr(int value, int len) { String result = String.valueOf(value); if (result.length() > len) { result = String.copyValueOf(result.toCharArray(), 0, len); }//from www. j ava2 s . c o m int count = len - result.length(); for (int i = 0; i < count; i++) { result = "0" + result; } return result; } }