Here you can find the source of zeroPad(String s, int len)
Parameter | Description |
---|---|
s | String that need to be padded with zero ahead "0" |
public static String zeroPad(String s, int len)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w. j a v a2 s . c o m * =====================================================================================<br> * This method is used to add padding "0" before a string so that the string has the expected * length. * * @param s * String that need to be padded with zero ahead "0" * * @return A zero "0" padding string */ public static String zeroPad(String s, int len) { String result = s; for (int i = s.length(); i < len; i++) result = "0".concat(result); return result; } }