Returns a string, of length at least minLength, consisting of string prepended with as many copies of padChar as are necessary to reach that length. For example, padStart("7", 3, '0') returns "007" padStart("2010", 3, '0') returns {@code
(String string, int minLength, char padChar)
| 87 | * @return the padded string |
| 88 | */ |
| 89 | public static String padStart(String string, int minLength, char padChar) { |
| 90 | checkNotNull(string); // eager for GWT. |
| 91 | if (string.length() >= minLength) { |
| 92 | return string; |
| 93 | } |
| 94 | StringBuilder sb = new StringBuilder(minLength); |
| 95 | for (int i = string.length(); i < minLength; i++) { |
| 96 | sb.append(padChar); |
| 97 | } |
| 98 | sb.append(string); |
| 99 | return sb.toString(); |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Returns a string, of length at least {@code minLength}, consisting of {@code string} appended |
nothing calls this directly
no test coverage detected