日期:2014-05-20  浏览次数:20690 次

DATE和DAY_OF_MONTH有啥区别
Calendar里的DATE和DAT_OF_MONTH有啥区别?

在帮助里看着好像没区别
为什么我做一道题的时候     把DATE设置成2结果是对的,可是把DAY_OF_MONTH设置成2就不对了,设置成1才对?

谢谢了!

------解决方案--------------------
package project;

import java.util.Calendar;

public class CalendarTable {
public CalendarTable() {
}

public static void main(String[] args) {
Calendar rightNow = Calendar.getInstance();
int year, month;
year = rightNow.get(Calendar.YEAR);
month = rightNow.get(Calendar.MONTH);

int num = rightNow.getActualMaximum(Calendar.DAY_OF_MONTH);

rightNow.set(year, month, 1);
int now = rightNow.get(Calendar.DAY_OF_WEEK);

System.out.println( "\t " + "\t " + "\t " + year + "年 " + " " + (month + 1) +
" 月 ");
System.out.println( "\t " + "日 " + "\t " + "一 " + "\t " + "二 " + "\t " + "三 " +
"\t " + "四 " + "\t " + "五 " + "\t " + "六 ");
for (int j = 1; j < (now); j++) {
System.out.print( "\t ");
}
for (int i = 1; i <= (num); i++) {
System.out.print( "\t " + i);
if ((i + now - 1) % 7 == 0) {
System.out.println();
}
}
}
}
这段代码是直接根据系统的时间打印当前时间的日历
你可以改一下 改成通过输入来打印日历