/**
* 计算周六日
* @param args
* @throws ParseException
*/
public static void main(String[] args) throws ParseException {
int year = 2018;
List<String> dateList=new ArrayList<String>();
SimpleDateFormat simdf = new SimpleDateFormat(“yyyy-MM-dd”);
Calendar calendar = new GregorianCalendar(year, 0, 1);
int i = 1;
while (calendar.get(Calendar.YEAR) < year + 1) {
calendar.set(Calendar.WEEK_OF_YEAR, i++);
calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
if (calendar.get(Calendar.YEAR) == year) {
System.out.println(“周日:”+simdf.format(calendar.getTime()));
dateList.add(simdf.format(calendar.getTime()));
}
calendar.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
if (calendar.get(Calendar.YEAR) == year) {
System.out.println(“周六:”+simdf.format(calendar.getTime()));
dateList.add(simdf.format(calendar.getTime()));
}
}
System.out.println(dateList.size());
}