怎么得到指定日期是星期几啊?

wzbwambition
04-07-25 2 242

java.util.Calendar c= java.util.Calendar.getInstance();
c.set(2004,6,28);
System.out.println(c.get(Calendar.DAY_OF_WEEK));
怎么老返回的跟实际对不上啊,各位帮忙看看

wzbwambition
2004-07-25 14:19

java.util.Calendar c= java.util.Calendar.getInstance();
c.set(2004,7,25);
System.out.println(c.get(c.DAY_OF_WEEK));
比如这个应该返回星期日,也就是7,我这里总是返回4。郁闷啊。

huzhigang
2004-07-26 08:38

jdk的文档指明:
month - the value used to set the MONTH time field. Month value is 0-based. e.g., 0 for January
月是以0开始的.
所以你指定的7实际是8月了