public static void main(String[] args) throws ParseException{
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date start = format.parse("2019-1-1 00:00:00");
Date end = format.parse("2019-5-30 00:00:00");
long time = start.getTime() + (long) (Math.random() * (end.getTime() - start.getTime()));
System.out.println(format.format(time));
}
<java>写随机时间
最新推荐文章于 2024-07-13 03:09:42 发布