Java Calendar.set(int year,int month,int day)设置时间有问题

import java.util.Calendar;

public class dateTutorial {

public static void main(String[] args) {

// create a calendar
Calendar cal = Calendar.getInstance();

// print current time
System.out.println("Current year is :" + cal.getTime());

// set the year,month and day to something else
cal.set(1995, 5, 25, 04, 15, 20);

// print the result
System.out.println("Altered year is :" + cal.getTime());
SimpleDateFormat dateformat=new SimpleDateFormat("yyyy-MM-dd ");
System.out.println("Altered year is :" + dateformat.format(cal.getTime()));
System.out.println("Altered year is :" + cal.get(Calendar.MONTH));
}
}
运行的结果是:

Current year is :Thu May 07 16:47:19 CST 2015
Altered year is :Sun Jun 25 04:15:20 CST 1995
Altered year is :1995-06-25
Altered year is :5
设置是5月,结果显示Jun 6月 而Calendar.MONTH 也是5月 这是怎么回事

Calendar 这个类其中月是个比较特别的,是从0开始计算的,如果你要显示5月,传入的就要是4..
温馨提示:答案为网友推荐,仅供参考