public class DateUtils {
public static LocalDate getQuarterEndTime(LocalDate date) {
Month month = date.getMonth();
int quarterMonth;
switch (month) {
case JANUARY: case FEBRUARY: case MARCH: quarterMonth = 3; break;
case APRIL: case MAY: case JUNE: quarterMonth = 6; break;
case JULY: case AUGUST: case SEPTEMBER: quarterMonth = 9; break;
default: quarterMonth = 12;
}
int year = date.getYear();
return LocalDate.of(year, quarterMonth,1).with(TemporalAdjusters.lastDayOfMonth());
}
}
网友评论