Starting from JDK 5, the equivalence class for a single thread is added to this class, which is StringBuilder. Compared to this class, you should usually use the StringBuilder class because it supports all the same operations, but because it does not perform synchronization, the speed is faster.
The following method functions
Sprintf0d (SB, 123, 5) -> 00123
Sprintf0d (SB, -123, 5) -> - 0123
/ ** * Before ゼ ゼ 付 加 结果 结果 结果 结果 る る る 列 列 ゼ ゼ ゼ ゼ ゼ ゼ ゼ ゼ ゼ ゼ ゼ ゼ ゼ ゼ ゼ ゼ ゼ ゼ 変 変 ゼ ゼ ゼ ゼ ゼ ゼ ゼ ゼ ゼ ゼ文 列 * / public static final stringbuilder sprintf0d (stringbuilder arg, int arg1, int arg2) {long temparg1 = (long) arg1; return arg = Sprintf0d (arg, temparg1, arg2);}
/ ** * Before the ゼ ゼ 付 加 し 结果 结果 结果 结果 结果 る る る 列 ゼ ゼ ゼ ゼ ゼ ゼ ゼ ゼ ゼ ゼ ゼ ゼ ゼ ゼ ゼ ゼ ゼ ゼ 変 ゼ ゼ ゼ 変 ゼ ゼ ゼ ゼ 変 変文 列 * / public static final stringbuilder sprintf0d (stringbuilder arg, long arg1, int arg2) {boolean flag = false; int Templength; string temp = ""; int J = 0; IF (arg2 <= 0) {Return Arg }} If (arg1 <0) {Flag = true; arg1 = math.abs (arg1); j = 1;}
Temp = String.Valueof (arg1); templength = arg2 - temp.Length () - j; for (int i = 0; i IF (Flag == True) {TEMP = "-" TEMP;} arg.append (temp); Return arg;} /// . StringBuilder / ** * add zeros before the number * @param sb * @param num * @param len * @return * / public static final StringBuilder sprintf0d (StringBuilder sb, long num, int len) {long lng = num; if (LNG <0L) {sb.append ('-'); LNG = -lng; len-;} long k = 10L; for (int I1 = 2; i1