随机数生成

来源:互联网 发布:mac os x ios下载 编辑:程序博客网 时间:2024/05/29 06:35
//生成唯一的num+1位随机数生成规则
public static String getOrderIdByUUID(int length){
int merChantId=1;//最大支持1-9个集群机器部署
int hashCodeV=UUID.randomUUID().toString().hashCode();
if(hashCodeV<0){
hashCodeV=-hashCodeV;
}
//0代表前面补0
//代表长度
//d代表参数为正整型
return merChantId+String.format("%0"+length+"d",hashCodeV);
}
0 0