import java.util.*;
import java.text.SimpleDateFormat;
public class My {
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.print("请输入年份:");
int year=input.nextInt();
System.out.print("请输入几年:");
int n=input.nextInt();
getbgf(year,n);
}
public static void getbgf(int year,int n)
{
SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd E");
int k=0;
Calendar cal=Calendar.getInstance();
while(k<n)
{
for(int i=0;i<12;i++)
{
cal.set(year, i, 13);
if (5==(cal.get(Calendar.DAY_OF_WEEK-1)))
{
System.out.print("黑色星期五:"+sdf.format(cal.getTime()));
}
}
year++;
k++;
}
}
}
没什么输不出结果呢? |