得到某年中所有星期二的日期
import java.text.DateFormat;import java.text.SimpleDateFormat;import java.util.Calendar;public class Test {public static void main(String[] args) {int year = 2010;Calendar calendar = Calendar.getInstance();DateFormat df = new SimpleDateFormat("yyyyMMdd");calendar.set(year, 0, 1);while (true) {if (calendar.get(Calendar.YEAR) != year) {break;}if (calendar.get(Calendar.DAY_OF_WEEK) == 3) { // 1=星期天 2=星期一 3=星期二 4=星期三 5=星期四 6=星期五 7=星期六System.out.println(df.format(calendar.getTime()));}calendar.set(Calendar.DATE, calendar.get(Calendar.DATE)+1);}}}