獲取當前日期至這一週的List

public static List<Date> dateToWeek() {
Date now=new Date();
Calendar calendar =new GregorianCalendar(); //實例化一個日曆類對象
List<Date> list = new ArrayList<Date>();
list.add(now); //當前時間可以先加入道list中
for (int a = 1; a < 7; a++) {
calendar.add(calendar.DATE,1); //每循環一次天數加一
list.add(calendar.getTime() );
}
return list;

}

就是怎麼簡單。。。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章