要求:实现控制台输出月历功能。
public String monthlycalendar(){ Calendar cal1 = new GregorianCalendar(TimeZone.getTimeZone("Asia/Shanghai")); System.out.println("周日\t周一\t周二\t周三\t周四\t周五\t周六\t"); //System.out.println(); //System.out.print("\t"); cal1.set(Calendar.MONTH,0); cal1.set(Calendar.DAY_OF_MONTH,29); int nowday = cal1.get(Calendar.DAY_OF_MONTH); cal1.set(Calendar.DAY_OF_MONTH,1); int startofweek = cal1.get(Calendar.DAY_OF_WEEK) - 1; for (int i = 0;i < startofweek;i++){ System.out.print("\t"); } switch (startofweek){ case 0: //System.out.println("星期日"); for (int i = 1;i < cal1.getActualMaximum(Calendar.DATE) + 1;i++){ if (i == nowday){ System.out.print(i + "*\t"); }else{ System.out.print(i + "