public class HellowWorldClass {
privatestatic Scannera;
privatestatic Scannerb;
public static void main(String[] args) {
// TODO Auto-generated method stub
a = new Scanner(System.in);
int year = a.nextInt();
System.out.println("请输入年份为:" +year);
b = new Scanner(System.in);
int month = b.nextInt();
System.out.println("请输入月份:"+month);
//title
System.out.println(" <<<<<<<<<<<<<<<<迷你版 万年历>>>>>>>>>> ");
System.out.println(" "+year+"年"+month+"月");
String title[] = {"日","一","二","三","四","五","六"};
for(inti=0;i<=6;i++){
System.out.print(title[i] +"\t");
}
System.out.print("\n");
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR,year);
cal.set(Calendar.MONDAY,month);
cal.set(Calendar.DATE, 1);
//用来获取当前的日期,是星期几
int weekday = cal.get(Calendar.DAY_OF_WEEK);
for(inti= 1;i<= weekday-1;i++){
System.out.print("\t");
}
int maxdate = cal.getActualMaximum(Calendar.DATE);//获取最大的天数
for(inti= 1;i<= maxdate;i++){
System.out.print(i +"\t");
if((i+weekday-1)%7 ==0){
System.out.print("\n");
}
}
}
}