根据时间生成随机Id

public class DateUtil {
    private static SimpleDateFormat sdf = new SimpleDateFormat("yyy");
    public static String getId(){
    	Random random = new Random();
    	Date date = new Date();
    	String resu = sdf.format(date)+(random.nextInt(1000)+1000);
    	return resu;
    }
    
}

直接调用即可。

猜你喜欢

转载自blog.csdn.net/qq_37333151/article/details/84847245