获得本周所有日期

 private String getOneDayOfWeek(int week, int weekDay){
        Calendar c = Calendar.getInstance();
        c.add(Calendar.WEEK_OF_YEAR, week);
        int preNowWeekDay = c.get(Calendar.DAY_OF_WEEK);
        int preSubDays = weekDay - preNowWeekDay;
        c.add(Calendar.DAY_OF_WEEK, preSubDays);
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
        return sf.format(c.getTime());
    }
   
    
for (int i = 0; i < 7; i++) {
    String x = "date"+i;
    x=getOneDayOfWeek(0, i + 2)

    }

//x即为本周7天日期

posted @ 2012-06-05 14:19  狂奔的蜗牛cn  阅读(182)  评论(0)    收藏  举报