剛開始使用new Date(),并通過date.getMonth(),和date.getDay()獲取,發(fā)現(xiàn)獲取時間一直不對,后來發(fā)現(xiàn)這兩個獲取方式是jdk1.1版本的,現(xiàn)在已經(jīng)不用了.
后來查看[Java ]doc文檔,MONTH字段解釋如下
Field number for get and set indicating the month.
This is a calendar-specific value.
The first month of the year is JANUARY which is 0;
the last depends on the number of months in a year.
馬個雞,這家伙不就是和數(shù)組list一個樣嗎,下標從0開始算得...
int month = (date.get(Calendar.MONTH))+1;
int day = date.get(Calendar.DAY_OF_MONTH);
獲取當前的月份和日期
試了一下,果然正確