美文网首页
计算某个日期对应季度的最后一天

计算某个日期对应季度的最后一天

作者: 哲人王 | 来源:发表于2019-04-18 15:45 被阅读0次
    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());
        }
    
    }
    

    相关文章

      网友评论

          本文标题:计算某个日期对应季度的最后一天

          本文链接:https://www.haomeiwen.com/subject/tudtgqtx.html