Here you can find the source of format(int num, int length)
public static String format(int num, int length)
//package com.java2s; //License from project: Apache License public class Main { public static String format(String str, int length) { while (str.length() > length) length++;//from ww w. j ava2 s . co m while (str.length() < length) { str = "0" + str; } return str; } public static String format(int num, int length) { String str = Integer.toHexString(num); return format(str, length); } }