package yj_test; import java.util.Calendar; import java.util.GregorianCalendar; public class yj_calendar { public static void main (String[] args){ GregorianCalendar d = new GregorianCalendar(); int today = d.get(Calendar.DAY_OF_MONTH); int month = d.get(Calendar.MONTH); d.set(Calendar.DAY_OF_MONTH,1); int weekday = d.get(Calendar.DAY_OF_WEEK); System.out.println("Sun Mon Tue Wen Thu Fri Sat"); for (int i = 1;i < weekday;i++){ System.out.print(" "); } do { System.out.printf("%3d",d.get(Calendar.DAY_OF_MONTH )); if (d.get(Calendar.DAY_OF_MONTH)==today){ System.out.print("*"); }else{ System.out.print(" "); } if (d.get(Calendar.DAY_OF_WEEK) == 7){ System.out.println(); } d.add(Calendar.DAY_OF_MONTH ,1); }while(d.get(Calendar.MONTH)==month); } }