package com.jeeplus.test.reimbursementsys.utils;

/**
 * @author: 徐滕
 * @version: 2022-06-13 14:50
 */
public class PublicUtil {
    /**
     * 字符串左补齐方法
     * @param src 原有字符串
     * @param len 返回字符串长度
     * @param ch 需要补齐的字符
     * @return
     */
    public static String padLeft(String src, int len, char ch) {
        int diff = len - src.length();
        if (diff <= 0) {
            return src;
        }

        char[] charr = new char[len];
        System.arraycopy(src.toCharArray(), 0, charr, diff, src.length());
        for (int i = 0; i < diff; i++) {
            charr[i] = ch;
        }
        return new String(charr);
    }
}
