int code = UUID.randomUUID().hashCode() % 1000000;
char[] chars = new char[6];
for (int i = 0; i < chars.length; i++) {
chars[i] = ‘0‘;
}
String verifyCode = new DecimalFormat(new String(chars)).format(Math.abs(code % 99999));
return verifyCode;
int number = UUID.randomUUID().hashCode() % 1000000;
int abs = Math.abs(number);
Random random = new Random();
StringBuffer buffer = new StringBuffer();
for (int i = 0 ; i < 6 ; i ++){
int i1 = random.nextInt(10);
buffer.append(i1);
}
String verifyCode = buffer.toString();
return verifyCode;
原文:https://www.cnblogs.com/javacat7/p/14673780.html