获取一定时间段内星期几的日期
String submitStr = "";
Date startDate = null, endDate = null;
DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try {
startDate = format.parse(startTime);
endDate = format.parse(endTime);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
long interval = 24*60*60*1000;
long mStartTime = startDate.getTime();
long mEndTime = endDate.getTime();
while(mStartTime <= mEndTime){ for(int i = 0; i < restList.size(); i++){ Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date(mStartTime)); if(calendar.get(Calendar.DAY_OF_WEEK) == Integer.parseInt(restList.get(i))){ submitStr += format.format(new Date(mStartTime)) + ","; } } mStartTime += interval; } submitStr = submitStr.substring(0, submitStr.length()-1);
要放到后台运行