LcoalDateTime
LocalDateTime now = LocalDateTime.now();
LocalDateTime end = LocalDateTime.now();
Duration duration = Duration.between(now,end);
//相差的天數
long days = duration.toDays();
//相差的小時數
long hours = duration.toHours();
//相差的分鍾數
long minutes = duration.toMinutes();
//相差毫秒數
long millis = duration.toMillis();
//相差的納秒數
long nanos = duration.toNanos();
LocalDate
LocalDate start = LocalDate.of(2020, 12, 27);
Period period = Period.between(start, LocalDate.now());
// 日期相差
int days = period.getDays();
// 相差月份
int months = period.getMonths();
// 相差年份
int years = period.getYears();
System.out.println(days +"-"+ months +"-"+ years);
// 更准確 - 開發用這個,省事
long dayse = LocalDate.now().toEpochDay() - start.toEpochDay();
System.out.println("相差天數" + dayse);