方式一
LocalDateTime date = LocalDateTime.now();
LocalDateTime firstDay = date.with(TemporalAdjusters.firstDayOfMonth());
LocalDateTime lastDay = date.with(TemporalAdjusters.lastDayOfMonth());
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd");
System.out.println(fmt.format(firstDay) + " 00:00:00");
System.out.println(fmt.format(lastDay) + " 23:59:59");
方式二
LocalDateTime date = LocalDateTime.now();
LocalDateTime firstDayTime = date.with(TemporalAdjusters.firstDayOfMonth());
LocalDate firstDay = LocalDate.from(firstDayTime);
LocalDateTime firstTime = LocalDateTime.of(firstDay, LocalTime.MIN);
LocalDateTime lastDayTime = date.with(TemporalAdjusters.lastDayOfMonth());
LocalDate lastDay = LocalDate.from(lastDayTime);
LocalDateTime lastTime = LocalDateTime.of(lastDay, LocalTime.MAX);
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
System.out.println(fmt.format(firstTime));
System.out.println(fmt.format(lastTime));