Here you can find the source of zeroPad(int n, int len)
Return a padded string with leading zeros.
Parameter | Description |
---|---|
n | Number. |
len | String length. |
public static String zeroPad(int n, int len)
//package com.java2s; public class Main { /**//from w ww .ja va 2s.c o m * <p> * Return a padded string with leading zeros. * </p> * @param n Number. * @param len String length. * @return Padded string. */ public static String zeroPad(int n, int len) { String s = n + ""; // for (int i = len - s.length(); i > 0; i--) { s = '0' + s; } // return s; } }