java10进制转A-Z26进制

把十进制转成26进制,A代表0,Z代表25,最低4位,不足补A

 

public static String to26Str(long l) {
        StringBuffer sb = new StringBuffer();
        int jinz = 26;
        boolean f = true;
        while (f) {
            sb.insert(0, ((char) (l % jinz + 65)));
            l = l / jinz;
            if (l == 0)
                f = false;
        }
        for (int i = sb.length(); 4 - i > 0; i++) {
            sb = new StringBuffer("A" + sb);
        }
        return sb.toString();
    }

 

你可能感兴趣的:(代码)