日期:2014-05-20 浏览次数:21002 次
package cn.ffcs.ct10000.card;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
public class TTEST {
public static String getCurrStrTime(int type){
Date date = new Date();
DateFormat formatter = null;
if(type == 1){
formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
}else if(type == 2){
formatter = new SimpleDateFormat("yyyy-MM"); //检查每月一次的业务
}else if(type == 3){
formatter = new SimpleDateFormat("yyyyMMddHHmmss");
}else{
//默认
formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
}
return formatter .format(date);
}
public static String getSno() {
Random rdm = new Random();
int i = rdm.nextInt(1000000)+1000000;
String str = "nx" + getCurrStrTime(3) + String.valueOf(i).substring(1,7);
return str;
}
public static void suijishu(){
//获得一个从100000到999999之间的整数
Random rdm = new Random();
for(int i=0; i<1000;i++){
int j;
j = rdm.nextInt(1000000)+1000000;
String str = "nx" + getCurrStrTime(3) + String.valueOf(j).substring(1,7);
System.out.println(str);
}
}
public static void t1(){
for(int i=0;i<100;i++){
String sno = getSno();
if(sno.length() != 2){
System.out.println(sno);
}
}
}
public static void t2(){
suijishu();
}
/**
* @param args
*/
public static void main(String[] args) {
// t1();
t2();
}
}