//打印未来几年的黑色星期五,判断每个月的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++;
}
}