更新时间:2022-02-07 21:19:00
你想要的是以下成语:c.get(Calendar.MONTH)
.
What you want is the following idiom: c.get(Calendar.MONTH)
.
Calendar.MONTH
本身只是一个内部常量,并且(希望)总是返回 2
.
Calendar.MONTH
per se is just an internal constant and will (hopefully) always return 2
.
示例
// We're in June at the time of writing
// Months are 0-based so June == 5
Calendar c = Calendar.getInstance();
System.out.println(Calendar.MONTH);
System.out.println(c.get(Calendar.MONTH));
输出
2
5
另请参阅:API