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;
|
}
|
|
}
|