例如,我想获取一周的开始日期和结束日期
2012-05-06 至 2012-05-12
2012-05-13 至 2012-05-19
我写的代码是
currWeekCalender.add(Calendar.WEEK_OF_YEAR, 1);
String dateStart = currWeekCalender.get(Calendar.YEAR) + "-" + addZero((currWeekCalender.get(Calendar.MONTH) + 1)) + "-" + addZero(currWeekCalender.getFirstDayOfWeek());
currWeekCalender.add(Calendar.DAY_OF_MONTH,7);
String dateEnd = currWeekCalender.get(Calendar.YEAR) + "-" + addZero((currWeekCalender.get(Calendar.MONTH) + 1)) + "-" + addZero(currWeekCalender.get(Calendar.DAY_OF_MONTH));
但结果不正确,我也想要前几周的日期。
谢谢