日期间隔
两种方式:
1.LocalDate
LocalDate.now().minusMonths(1);
2.Calendar
Calendar instance = Calendar.getInstance();
instance.add(Calendar.MONTH,-1);
System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(instance.getTime()));
时间间隔
//计算时间差
Instant instant1=Instant.now();
Thread.sleep(1000);
Instant instant2 = Instant.now();
System.out.println(Duration.between(instant1,instant2).toMillis());