安吉做网站/百度正版下载并安装
生成随机ID:当前年月日时分秒 +五位随机数
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;/*** 生成随机ID:当前年月日时分秒 +五位随机数*/
public class IdRandomUtils {/*** 生成随机ID:当前年月日时分秒 +五位随机数*/public static Long getRandomID() {SimpleDateFormat simpleDateFormat;simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");Date date = new Date();String str = simpleDateFormat.format(date);Random random = new Random();int rannum = (int) (random.nextDouble() * (99999 - 10000 + 1)) + 10000;// 获取5位随机数return Long.valueOf(str + rannum);// 当前时间}/*** 测试* @param args*/public static void main(String[] args) {System.out.println(IdRandomUtils.getRandomID());}
}