java8 获取当前时间和指定时间戳间隔天数
2019-08-21 本文已影响0人
Jesus丫
/**
* 获取当前时间和endTime间隔天数
* @param endTime
* @return 天数
*/
public static long daysBetween(long endTime) {
LocalDate startTime = LocalDate.now();
return startTime.until(Instant.ofEpochMilli(endTime).atZone(ZoneOffset.ofHours(8)).toLocalDate(), ChronoUnit.DAYS);
}