本文介紹了日歷上課時間月份不匹配的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
Calendar c = Calendar.getInstance();
System.out.println("Mili->>" + c.getTimeInMillis());
System.out.println("Month ->>" + Calendar.MONTH);
雖然我得到了毫秒格式的正確時間,但月份顯示為 2(三月??)為什么會這樣?
Though I am getting correct time in millisec format, Month is showing as 2 (March??) Why so?
下面是輸出
米利->>1434029840778
Mili->>1434029840778
月 ->>2
Month ->>2
推薦答案
你想要的是以下成語: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
這篇關于日歷上課時間月份不匹配的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!