一、获取本周
weekFirst_date=new Date();
weekLast_date=new Date();
weekFirst_calendar=Calendar.getInstance();
weekLast_calendar=Calendar.getInstance();
weekFirst_time=null;
weekLast_time=null;
weekFirst_calendar.setFirstDayOfWeek(Calendar.MONDAY);
weekFirst_calendar.add(Calendar.WEEK_OF_MONTH,0);
weekFirst_calendar.set(Calendar.DAY_OF_WEEK,Calendar.MONDAY);
weekFirst_date=weekFirst_calendar.getTime();
weekFirst_time=formatter_1.format(weekFirst_date);
StringBuffer weekFirst_str=new StringBuffer().append(weekFirst_time).append(" 00:00:00");
weekFirst_time=weekFirst_str.toString();
prev_time.setText(weekFirst_time);
weekLast_calendar.set(weekFirst_calendar.DAY_OF_MONTH,weekFirst_calendar.get(weekFirst_calendar.DAY_OF_MONTH)+7);
weekLast_date=weekLast_calendar.getTime();
weekLast_time=formatter_1.format(weekLast_date);
StringBuffer weekLast_str=new StringBuffer().append(weekLast_time).append(" 00:00:00");
weekLast_time=weekLast_str.toString();
next_time.setText(weekLast_time);
二、以周为单位变化
1、向前推一周
week_cal_1.set(Calendar.DAY_OF_MONTH,week_cal_1.get(Calendar.DAY_OF_MONTH)-7);
week_date_1=week_cal_1.getTime();
week_time_1=formatter_1.format(week_date_1);
StringBuffer str_weekFirst=new StringBuffer().append(week_time_1).append(" 00:00:00");
week_time_1=str_weekFirst.toString();
text1.setText(week_time_1);
week_cal_2.set(Calendar.DAY_OF_MONTH,week_cal_2.get(Calendar.DAY_OF_MONTH)-7);
week_date_2=week_cal_2.getTime();
week_time_2=formatter_1.format(week_date_2);
StringBuffer str_weekLast=new StringBuffer().append(week_time_2).append(" 00:00:00");
week_time_2=str_weekLast.toString();
text2.setText(week_time_2);
2、向后推一周
week_cal_1.set(Calendar.DAY_OF_MONTH,week_cal_1.get(Calendar.DAY_OF_MONTH)+7);
week_date_1=week_cal_1.getTime();
week_time_1=formatter_1.format(week_date_1);
StringBuffer str_weekFirst=new StringBuffer().append(week_time_1).append(" 00:00:00");
week_time_1=str_weekFirst.toString();
text1.setText(week_time_1);
week_cal_2.set(Calendar.DAY_OF_MONTH,week_cal_2.get(Calendar.DAY_OF_MONTH)+7);
week_date_2=week_cal_2.getTime();
week_time_2=formatter_1.format(week_date_2);
StringBuffer str_weekLast=new StringBuffer().append(week_time_2).append(" 00:00:00");
week_time_2=str_weekLast.toString();
text2.setText(week_time_2);