2021与蓝度共同重构项目,服务端
zhanzhiqin
2022-08-15 edbb2fe4eabbb7c526fb2f7313bead37d38928e2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.sandu.ximon.admin.utils;
 
/**
 * 补位
 */
public class SupplementUtils {
 
 
    public static String suppleZero(String hex,Integer totalBit){
 
        if (hex.length()>totalBit) {
            return hex.substring(0, totalBit);
        } else if (hex.length()==totalBit){
            return hex;
        }
        totalBit = totalBit - hex.length();
 
        for(int i=0;i<totalBit;i++){
            hex = "0" + hex;
        }
        return hex;
    }
 
    public static String suppleZero(Integer hexInt,Integer totalBit){
 
        String hex = hexInt+"";
 
        if (hex.length()>totalBit) {
            return hex.substring(0, totalBit);
        } else if (hex.length()==totalBit){
            return hex;
        }
        totalBit = totalBit - hex.length();
 
        for(int i=0;i<totalBit;i++){
            hex = "0" + hex;
        }
        return hex;
    }
 
}