public static void main(String[] args) {
LocalDateTime now = LocalDateTime.now();
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH:mm:ss");
LocalDateTime yearStart = now.with(TemporalAdjusters.firstDayOfYear()).with(LocalTime.MIN);
LocalDateTime yearEnd = now.with(TemporalAdjusters.lastDayOfYear()).with(LocalTime.MAX);
System.out.println("当前年的开始时间:" + yearStart.format(fmt));
System.out.println("当前年的结束时间:" + yearEnd.format(fmt));
LocalDateTime monthStart = now.with(TemporalAdjusters.firstDayOfMonth()).with(LocalTime.MIN);
LocalDateTime monthEnd = now.with(TemporalAdjusters.lastDayOfMonth()).with(LocalTime.MAX);
System.out.println("当前月的开始时间:" + monthStart.format(fmt));
System.out.println("当前月的结束时间:" + monthEnd.format(fmt));
int dayOfWeek = now.getDayOfWeek().getValue();
LocalDateTime weekStart = now.minusDays(7 - dayOfWeek).with(LocalTime.MIN);
LocalDateTime weekEnd = now.plusDays(7 - dayOfWeek).with(LocalTime.MAX);
System.out.println("当前周的开始时间:" + weekStart.format(fmt));
System.out.println("当前周的结束时间:" + weekEnd.format(fmt));
LocalDateTime dayStart = now.with(LocalTime.MIN);
LocalDateTime dayEnd = now.with(LocalTime.MAX);
System.out.println("当天的开始时间:" + dayStart.format(fmt));
System.out.println("当天的结束时间:" + dayEnd.format(fmt));
}