特定日期的取得
LocalDateTime nowLocalDateTime = LocalDateTime.now();
LocalDateTime startLocalDateTime;
LocalDateTime endLocalDateTime;
// 今天的第0秒
startLocalDateTime = nowLocalDateTime.with(LocalTime.MIN);
//今天的最后一秒
endLocalDateTime = nowLocalDateTime.with(LocalTime.MAX);
log.debug(startLocalDateTime + "---" + endLocalDateTime);
//这周的第0秒,从周一开始
startLocalDateTime = nowLocalDateTime.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)).with(LocalTime.MIN);
// 这周的最后一秒,从周日结束
endLocalDateTime = nowLocalDateTime.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY)).with(LocalTime.MAX);
log.debug(startLocalDateTime + "---" + endLocalDateTime);
//这个月的第一秒
startLocalDateTime = nowLocalDateTime.with(TemporalAdjusters.firstDayOfMonth()).with(LocalTime.MIN);
//这个月的最后一秒
endLocalDateTime = nowLocalDateTime.with(TemporalAdjusters.lastDayOfMonth()).with(LocalTime.MAX);
log.debug(startLocalDateTime + "---" + endLocalDateTime);
比较两个时间,是否在特定时间段内
createLocalDateTime.isAfter(startTime) && createLocalDateTime.isBefore(endTime)
java.util.Date 转 LocalDateTime
LocalDateTime now= LocalDateTime.ofInstant(new Date().toInstant(), ZoneId.systemDefault());