目录
工具类
代码语言:javascript
复制// 获取一年的工作日
public static List getYearDays(String year){
List<String> CalList = new ArrayList<>();
//请注意月份是从0-11,天数是1, 2013-1-1 至 2013-12-31
Calendar start = Calendar.getInstance();
start.set(Integer.parseInt(year), 0, 1); //2013-1-1 开始
Calendar end = Calendar.getInstance();
end.set(Integer.parseInt(year) 1, 0, 0); // 2014--0-0结束,2014-1-1不算
int sumSunday = 0;
int sumSat = 0;
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
while(start.compareTo(end) <= 0) {
int w = start.get(Calendar.DAY_OF_WEEK);
if(w == Calendar.SUNDAY)
sumSunday ;
if(w == Calendar.SATURDAY)
sumSunday ;
//打印每天
CalList.add(format.format(start.getTime()));
// System.out.println(format.format(start.getTime()));
//循环,每次天数加1
start.set(Calendar.DATE, start.get(Calendar.DATE) 1);
}
return CalList;
}