两个时间相减 得到他们之间的时间差
public static long getComputationTime(Date start,Date TheEnd) {
long diff = start.getTime() - TheEnd.getTime();
long diffHours = diff / (60 * 60 * 1000);
return diffHours;
}
//生成验证码
public static String achieveCode() {
String[] beforeShuffle= new String[] {"0","1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F",
"G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a",
"b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
"w", "x", "y", "z" };
List list = Arrays.asList(beforeShuffle);
Collections.shuffle(list);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < list.size(); i++) {
sb.append(list.get(i));
}
String afterShuffle = sb.toString();
String result = afterShuffle.substring(3, 9);
System.out.print(result);
return result;
}
两个时间相减 和 生成验证码
猜你喜欢
转载自blog.csdn.net/qq_29072049/article/details/83543923
今日推荐
周排行