得到当前月份所有的周一至周五

//根据年月计算出当月工作日
private List getWorkdays(Calendar cal, int year, int month) {
List dates = new ArrayList();


cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month - 1);
cal.set(Calendar.DATE, 1);


while (cal.get(Calendar.YEAR) == year && cal.get(Calendar.MONTH) < month) {
int day = cal.get(Calendar.DAY_OF_WEEK);


if (!(day == Calendar.SUNDAY || day == Calendar.SATURDAY)) {
dates.add((Date) cal.getTime().clone());
}
cal.add(Calendar.DATE, 1);
}
return dates;
}

你可能感兴趣的:(得到当前月份所有的周一至周五)