LocalDateTime获取今天最早时刻和最晚时刻

先获取,再格式化 ;
LocalDateTime of = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
System.out.println( of.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));

LocalDateTime max = LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
System.out.println(max.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));

或者
LocalDateTime.of(LocalDate.now(),LocalTime.of(0,0,0,0))
LocalDateTime.of(LocalDate.now(),LocalTime.of(23,59,59))

posted @ 2024-09-12 13:39  梧桐将秋色  阅读(285)  评论(0编辑  收藏  举报