private ArrayList<String> monthNum(String beginTime, String endTime) {
String mid ="";
if (beginTime==null||"".equals(beginTime)||endTime==null||"".equals(endTime)) {
logger.error("处理月份计算,开始时间或结束时间不能为空!beginTime:【{}】,endTim:【{}】", beginTime, endTime);
return null;
}
if (beginTime.compareTo(endTime) > 0){
mid =beginTime;
beginTime=endTime;
endTime=mid;
};
List<DateTime> dateTimes = DateUtil.rangeToList(DateUtil.parse(beginTime+"01"), DateUtil.parse(endTime+"01"), DateField.MONTH);
ArrayList<Object> monthList = new ArrayList<>();
for (DateTime time : dateTimes) {
String s = DateUtil.format(time, "yyMM");
monthList.add(s);
}
return monthList;
}
|