实现生成指定范围的随机日期
- 单纯为了实现目的 的简单代码
package grammer1;
import java.util.Calendar;
import java.util.Date;
public class Rond3 {
public static void main(String[] args) {
var c = Calendar.getInstance();
c.set(2008, 11, 31);
long ss = c.getTime().getTime();
c.set(2020, 11, 31);
long xx = c.getTime().getTime();
double ee=Math.random()*(xx-ss)+ss;
long ll = (long) ee;
var dd=new Date (ll);
System.out.println(String.format("%1$tY年%1$tm月%1$td日",dd));
}
}