原文地址:
http://solomons.javaeye.com/blog/193686
获取当前日期所在星期的7个日期,记下来,以后用得着:
Java代码
Date date = new Date();
SimpleDateFormat dateformat = new SimpleDateFormat("yyyyMMdd");
Calendar c = new GregorianCalendar();
c.setFirstDayOfWeek(Calendar.MONDAY-1);
c.setTime(date);
String[] d = new String[7];
for(int i=0;i<7;i++){
c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek()+i);
d[i] = dateformat.format(c.getTime());
System.out.println(d[i]);
}