public static String genRegionCode(String caller, String buildTime, int regions) {
int len = caller.length();
//取出主叫后四位
String lastPhone = caller.substring(len - 4);
//取出年和月 buildTime:2018-06-22 13:27:21
String ym = buildTime
.replaceAll("-", "")
.replaceAll(" ", "")
.replaceAll(":", "")
.substring(0, 6);
//离散操作1
Integer x = Integer.valueOf(lastPhone) ^ Integer.valueOf(ym);
//离散操作2
int y = x.hashCode();
//生成分区号
int regionCode = y % regions;
//格式化分区号
DecimalFormat df = new DecimalFormat("00");
return df.format(regionCode);
}
我的项目中设计的RowKey
最新推荐文章于 2022-06-26 21:16:55 发布
