Here you can find the source of addLeadingZerosToNumber(long number, int length)
public static String addLeadingZerosToNumber(long number, int length)
//package com.java2s; //License from project: Apache License public class Main { public static String addLeadingZerosToNumber(long number, int length) { //the digits in the "number" is greater than or equal to the "length" if (length <= ((int) Math.log10(number) + 1)) return String.valueOf(number); return String.format("%0" + length + "d", number); }/*from w w w . jav a 2 s . com*/ }