/** * 一周的第一天 * * @param localDate 当地日期 * @return {@link LocalDate} */ public static LocalDate firstDayOfWeek(LocalDate localDate){ return localDate.with(DayOfWeek.MONDAY); } /** * 一周的最后一天 * * @param localDate 当地日期 * @return {@link LocalDate} */ public static LocalDate lastDayOfWeek(LocalDate localDate){ return localDate.with(DayOfWeek.SUNDAY); } /** * 月的第一天 * * @param localDate 当地日期 * @return {@link LocalDate} */ public static LocalDate firstDayOfMonth(LocalDate localDate){ return localDate.with(TemporalAdjusters.firstDayOfMonth()); } /** * 月的最后一天 * * @param localDate 当地日期 * @return {@link LocalDate} */ public static LocalDate lastDayOfMonth(LocalDate localDate){ return localDate.with(TemporalAdjusters.lastDayOfMonth()); } /** * 每年的第一天 * * @param localDate 当地日期 * @return {@link LocalDate} */ public static LocalDate firstDayOfYear(LocalDate localDate){ return localDate.with(TemporalAdjusters.firstDayOfYear()); } /** * 每年的最后一天 * * @param localDate 当地日期 * @return {@link LocalDate} */ public static LocalDate lastDayOfYear(LocalDate localDate){ return localDate.with(TemporalAdjusters.lastDayOfYear()); }
java8 LocalDate方法记录
于 2023-09-15 00:23:21 首次发布