@Test public void testZpad_01() { assertEquals("01", "00whatever|", StringUtil.zpad("whatever", 10, "|")); assertEquals("02", "00whatever|||", StringUtil.zpad("whatever", 10, "|||")); assertEquals("03", "0whatever|", StringUtil.zpad("whatever", 9, "|")); assertEquals("04", "whatever|", StringUtil.zpad("whatever", 8, "|")); assertEquals("05", "whatever", StringUtil.zpad("whatever", 7)); assertEquals("06", "whatever", StringUtil.zpad("whatever", 6)); String hour = StringUtil.zpad(7, 2, ":"); String minute = StringUtil.zpad(38, 2, ":"); String sec = StringUtil.zpad(6, 2); String time = hour + minute + sec; assertEquals("07", "07:38:06", time); }
public static String zpad(Object obj, int width, String separator) { return lpad(obj, width, '0', separator); }
StringUtil { public static String zpad(Object obj, int width, String separator) { return lpad(obj, width, '0', separator); } }
StringUtil { public static String zpad(Object obj, int width, String separator) { return lpad(obj, width, '0', separator); }  }
StringUtil { public static String zpad(Object obj, int width, String separator) { return lpad(obj, width, '0', separator); }  static String substr(String string, int from); static String substr(String string, int from, int length); static String zpad(Object obj, int width, String separator); static String zpad(Object obj, int width); static String lpad(Object obj, int width, String separator); static String pad(Object obj, int width); static String pad(Object obj, int width, char padChar); static String pad(Object obj, int width, char padChar, String separator); static String lpad(Object obj, int width); static String lpad(Object obj, int width, char padChar); static String lpad(Object obj, int width, char padChar, String separator); static String rpad(Object obj, int width, String separator); static String rpad(Object obj, int width); static String rpad(Object obj, int width, char padChar); static String rpad(Object obj, int width, char padChar, String separator); static String substring(String string, int from, int to); static String toString(byte[] bytes); static String lchop(String string, String word); static String rchop(String string, String word); static String[] split(String s, String delim); static String[] split(String s, String delim, int numParts); static String trim(String s, char c); static String ltrim(String s, char c); static String trim(String s, char... chars); static String trim(String s, String chars); static String rtrim(String s, char c); static boolean isTrue(String s); static boolean isTrue(String s, boolean dfault); static String getResourceAsString(String path); static InputStream toInputStream(String s); static InputStream toInputStream(String s, String charset); static String fromInputStream(InputStream is); static String fromInputStream(InputStream is, String charset); static String fromInputStream(InputStream is, String charset, int bufsize); static int toInt(String s); static String emptyIfNull(String str); }
StringUtil { public static String zpad(Object obj, int width, String separator) { return lpad(obj, width, '0', separator); }  static String substr(String string, int from); static String substr(String string, int from, int length); static String zpad(Object obj, int width, String separator); static String zpad(Object obj, int width); static String lpad(Object obj, int width, String separator); static String pad(Object obj, int width); static String pad(Object obj, int width, char padChar); static String pad(Object obj, int width, char padChar, String separator); static String lpad(Object obj, int width); static String lpad(Object obj, int width, char padChar); static String lpad(Object obj, int width, char padChar, String separator); static String rpad(Object obj, int width, String separator); static String rpad(Object obj, int width); static String rpad(Object obj, int width, char padChar); static String rpad(Object obj, int width, char padChar, String separator); static String substring(String string, int from, int to); static String toString(byte[] bytes); static String lchop(String string, String word); static String rchop(String string, String word); static String[] split(String s, String delim); static String[] split(String s, String delim, int numParts); static String trim(String s, char c); static String ltrim(String s, char c); static String trim(String s, char... chars); static String trim(String s, String chars); static String rtrim(String s, char c); static boolean isTrue(String s); static boolean isTrue(String s, boolean dfault); static String getResourceAsString(String path); static InputStream toInputStream(String s); static InputStream toInputStream(String s, String charset); static String fromInputStream(InputStream is); static String fromInputStream(InputStream is, String charset); static String fromInputStream(InputStream is, String charset, int bufsize); static int toInt(String s); static String emptyIfNull(String str); static final String EMPTY; }