Java tutorial
//package com.java2s; // and/or modify it under the terms of the GNU General Public License public class Main { private static String zeroes = "00000000000000000000000000000000"; public static String integerString(final Object value, final int desimals) { String str = Long.toString(((Number) value).longValue()); if (desimals == 0 || str.length() == zeroes.length()) { return str; } return zeroes.substring(0, desimals - str.length()) + str; } }