java 生成不重复的随机数

import java.text.SimpleDateFormat;
import java.util.Date;

public class Test2 {
public static void main(String[] args){
SimpleDateFormat formatter2 = new SimpleDateFormat ("yyyy年MM月dd日 HH:mm:ss ");
SimpleDateFormat formatter = new SimpleDateFormat ("MMddHHmmss");
Date curDate = new Date(System.currentTimeMillis());//获取当前时间
String str = formatter.format(curDate);
String cur = str.substring(0,2);
String cur2 = str.substring(2,4);
String temp = (Integer.parseInt(cur)+Integer.parseInt(cur2))+""+str.substring(4);
int cur_id = Integer.parseInt(temp.substring(0,4))+Integer.parseInt(temp.substring(4));
System.out.println(cur_id);
}

}

posted @ 2016-03-09 10:30  a318013800  阅读(1166)  评论(0编辑  收藏  举报