根据所传参数,计算前几周或者后几周的周一和周日的日期
传正数获取未来周一和周日的日期,传负数获取过去周一和周日的日期
public static String getPreOrNextMonSunDate(int num){
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar1 = Calendar.getInstance();
Calendar calendar2 = Calendar.getInstance();
int dayOfWeek=calendar1.get(Calendar.DAY_OF_WEEK)-1;
int offset1=1-dayOfWeek;
int offset2=7-dayOfWeek;
calendar1.add(Calendar.DATE, offset1+7*num);
calendar2.add(Calendar.DATE, offset2+7*num);
Date timePreMonday= calendar1.getTime();
Date timeThisMonday = calendar2.getTime();
String preMonday = simpleDateFormat.format(timePreMonday);//获取符合要求格式的上周周一日期
String nextSunday = simpleDateFormat.format(timeThisMonday);//获取符合要求格式的上周周日的日期
return preMonday+","+nextSunday;
}