pgty
发贴: 19
积分: 0
|
于 2004-10-20 23:53
好了 应该是这样的
不过输出来的格式不对哦 import java.util.*;
public class CalendarTest { 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 The Wed Thu Fri Set");
for(int i=Calendar.SUNDAY;i<weekday;i++) System.out.print(" ");
do { int day = d.get(Calendar.DAY_OF_MONTH); if (day<10) { System.out.print(" "); } System.out.print(day);
if (day==today) { System.out.print("* "); } else System.out.print(" "); if (weekday == Calendar.SATURDAY) { System.out.println(); } d.add(Calendar.DAY_OF_WEEK,1); } while (d.get(Calendar.MONTH)==month); if (weekday!=Calendar.SUNDAY) { System.out.println(); }
}
};
pgty edited on 2004-10-20 23:57
|