Java Zero Format zeroEsquerda(String s1, int tamString)

Here you can find the source of zeroEsquerda(String s1, int tamString)

Description

zero Esquerda

License

Apache License

Declaration

public String zeroEsquerda(String s1, int tamString) 

Method Source Code

//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);
    }
}

Related

  1. zeroConvert(String src)
  2. zerocount(int v)
  3. zeroCount(long n)
  4. zeroDiv(double numerator, double denominator)
  5. zeroes(final int ch)
  6. zeroExtend(long value, int inputBits)
  7. zeroFill(float[] array)
  8. zeroFill(int iv, int len)
  9. zeroFill(int num, int size, String character)