Here you can find the source of zeroEsquerda(String s1, int tamString)
public String zeroEsquerda(String s1, int tamString)
//package com.java2s; //License from project: Apache License public class Main { public String zeroEsquerda(String s1, int tamString) { while (s1.length() < tamString) { s1 = "0" + s1; }// www. j ava 2 s.c o m return s1; } public static String zeroEsquerda(int x, int casas) { if (x < Math.pow(10, casas)) { String r = String.valueOf(x); for (int i = r.length(); i < casas; i++) { r = "0" + r; } return r; } return String.valueOf(x); } }