如题
找了好多资料,还是没有找到想要的结果
请各位帮帮忙
非常感谢

解决方案 »

  1.   

    你要指定个生成范围才行,否则跨度太大了
    Random rand = new Random();
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    Calendar cal = Calendar.getInstance();
    cal.set(1900, 0, 1);
    long start = cal.getTimeInMillis();
    cal.set(2008, 0, 1);
    long end = cal.getTimeInMillis();
    for(int i = 0; i < 10; i++) {
    Date d = new Date(start + (long)(rand.nextDouble() * (end - start)));
    System.out.println(format.format(d));
    }