public static List<String> getMonthBetweenDate(Date startDate, Date endDate){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
List<String> dateList= new ArrayList<String>();
try {
Calendar calendar = Calendar.getInstance();
while (startDate.getTime()<=endDate.getTime()){
dateList.add(sdf.format(startDate));
calendar.setTime(startDate);
calendar.add(Calendar.DAY_OF_MONTH, 1);
startDate=calendar.getTime();
}
} catch (Exception e) {
e.printStackTrace();
}
return list;
}
获取时间段内的日期
最新推荐文章于 2024-07-12 15:51:39 发布