Here you can find the source of getWeekDateList(Date today, int index)
Parameter | Description |
---|---|
today | the today |
index | the index |
Parameter | Description |
---|
public static ArrayList<Date> getWeekDateList(Date today, int index)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.Calendar; import java.util.Date; public class Main { /**/*from w w w.jav a 2 s. c o m*/ * Gets week date list. * * @param today the today * @param index the index * @return ArrayList<Date> week date list * @throws * @Title: getWeekDateList * @Description: */ public static ArrayList<Date> getWeekDateList(Date today, int index) { ArrayList<Date> list = new ArrayList<Date>(); Calendar calendar = Calendar.getInstance(); calendar.setTime(today); if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { calendar.add(Calendar.WEEK_OF_YEAR, -1); } calendar.add(Calendar.WEEK_OF_YEAR, index); calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); for (int i = 0; i <= 6; i++) { Calendar c = Calendar.getInstance(); c.setTime(calendar.getTime()); c.add(Calendar.DAY_OF_MONTH, i); Date d = c.getTime(); list.add(d); } if (list.size() == 0) { list.add(today); } return list; } }