public static List<Date> dateToWeek(Date mdate) {
int b = mdate.getDay();
Date fdate;
List<Date> list = new ArrayList<Date>();
Long fTime = mdate.getTime() - b * 24 * 3600000;
for (int a = 1; a <= 7; a++) {
fdate = new Date();
fdate.setTime(fTime + (a * 24 * 3600000));
list.add(a-1, fdate);
}
return list;
}
public static String getWeek(Date date){
SimpleDateFormat sdf = new SimpleDateFormat("EEEE");
String week = sdf.format(date);
return week;
}
private static List<Date> dateToMonth(Date mdate) {
List<Date> list = new ArrayList<Date>();
Calendar cal = Calendar.getInstance();
cal.setTime(mdate);
cal.set(Calendar.DATE, 1);
int month = cal.get(Calendar.MONTH);
while(cal.get(Calendar.MONTH) == month){
list.add(cal.getTime());
cal.add(Calendar.DATE, 1);
}
return list;
}