计算环比日期选择

if ("week".equals(dto.getDatetype())) {
            prm.setStartDate(Integer.parseInt(beginDate.minusWeeks(1).withDayOfWeek(1).toString(DateUtils.DAY_FORMAT)));
            prm.setEndDate(Integer.parseInt(endDate.minusWeeks(1).withDayOfWeek(7).toString(DateUtils.DAY_FORMAT)));
        }
        if ("month".equals(dto.getDatetype())) {
            prm.setStartDate(Integer.parseInt(beginDate.minusMonths(1).withDayOfMonth(1).toString(DateUtils.DAY_FORMAT)));
            prm.setEndDate(Integer.parseInt(endDate.minusMonths(1).dayOfMonth().withMaximumValue().toString(DateUtils.DAY_FORMAT)));
        }
        if ("year".equals(dto.getDatetype())) {
            prm.setStartDate(Integer.parseInt(beginDate.minusYears(1).withDayOfYear(1).toString(DateUtils.DAY_FORMAT)));
            prm.setEndDate(Integer.parseInt(endDate.minusYears(1).dayOfYear().withMaximumValue().toString(DateUtils.DAY_FORMAT)));
        }
        if ("yesterday".equals(dto.getDatetype())) {
            prm.setStartDate(Integer.parseInt(beginDate.minusDays(1).toString(DateUtils.DAY_FORMAT)));
            prm.setEndDate(Integer.parseInt(endDate.minusDays(1).toString(DateUtils.DAY_FORMAT)));
        }

 

posted @ 2021-11-01 17:17  江湖小学生  阅读(155)  评论(0编辑  收藏  举报