import java.text.DateFormat; |
import java.text.ParseException; |
import java.text.SimpleDateFormat; |
import java.util.*; |
public class Main{ |
public static void main(String[] args ) throws ParseException { |
Scanner scan = new Scanner(System.in); |
int year = scan.nextInt(); |
int month = scan.nextInt(); |
|
Calendar cal = Calendar.getInstance(); |
Calendar calend = Calendar.getInstance(); |
cal.clear(); //清除获得的系统时间 |
calend.clear(); |
cal.set(year, month- 1 , cal.getActualMinimum(Calendar.DAY_OF_MONTH)); //设置这个月的第一天,月份是0-11 |
calend.set(year, month- 1 , calend.getActualMaximum(Calendar.DAY_OF_MONTH)- 1 ); //设置为这个月的最后一天 |
|
DateFormat df = new SimpleDateFormat( "yyyy-MM-dd" ); |
|
while (cal.getTime().getTime() <= calend.getTime().getTime()) { |
if ((cal.get(Calendar.DAY_OF_WEEK)== 7 ) || (cal.get(Calendar.DAY_OF_WEEK)== 1 )) { //从星期天算起,周二返回为3 |
System.out.println(df.format(cal.getTime())); |
} |
cal.add(Calendar.DAY_OF_MONTH, 1 ); //日期+1 |
} |
|
scan.close(); |
} |
} |