//打印未來幾年的黑色星期五,判斷每個月的13號是否是星期五
public static void getBlackFri(String year,int n){
//year爲輸入的年份,n爲未來多少年
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd E");
int years = Integer.parseInt(year);
int k=0;
Calendar cal = new GregorianCalendar();
while(k<n){
for (int i = 1; i <= 12; i++) {
cal.set(years, i,13);
if(5==(cal.get(Calendar.DAY_OF_WEEK)-1)){
System.out.println("黑色星期五:"+sdf.format(cal.getTime()));
}
}
years++;
k++;
}
}