package com.smppw.common.timerange;

import com.smppw.constants.DateConst;
import com.smppw.common.pojo.enums.TimeRange;
import com.smppw.utils.DateUtil;

import java.util.Calendar;
import java.util.Date;

public class Last5Years implements AbstractTimeRange{

    @Override
    public String generateStartDate(String endDateStr, TimeRange timeRange) {
        Date endDate = DateUtil.StringToDate(endDateStr);
        Calendar endDateCalendar = Calendar.getInstance();
        endDateCalendar.setTime(endDate);
        endDateCalendar.add(Calendar.YEAR, -5);
        Date startDate = endDateCalendar.getTime();
        return DateUtil.DateToString(startDate, DateConst.YYYY_MM_DD);
    }
}
