|
@@ -1300,7 +1300,12 @@ public class DateUtil {
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
calendar.setTime(startDate);
|
|
|
|
|
|
- while (calendar.getTime().compareTo(endDate) <= 0) { // 包含endDate所在的月份
|
|
|
+ Calendar endCalendar = Calendar.getInstance();
|
|
|
+ endCalendar.setTime(endDate);
|
|
|
+
|
|
|
+ while (calendar.get(Calendar.YEAR) < endCalendar.get(Calendar.YEAR) ||
|
|
|
+ (calendar.get(Calendar.YEAR) == endCalendar.get(Calendar.YEAR) &&
|
|
|
+ calendar.get(Calendar.MONTH) <= endCalendar.get(Calendar.MONTH))) {
|
|
|
monthList.add(DateUtil.format(calendar.getTime(), "yyyy-MM"));
|
|
|
calendar.add(Calendar.MONTH, 1);
|
|
|
}
|
|
@@ -1309,6 +1314,7 @@ public class DateUtil {
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
public static List<String> getYearList(Date startDate, Date endDate) {
|
|
|
List<String> yearList = new ArrayList<>();
|
|
|
Calendar calendar = Calendar.getInstance();
|