//返回周一日期字符串
public static String getMonDay(){
Date date =new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.setFirstDayOfWeek(Calendar.MONDAY);
calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
calendar.set(Calendar.HOUR_OF_DAY,0);
calendar.set(Calendar.MINUTE,0);
calendar.set(Calendar.SECOND,0);
calendar.set(Calendar.MILLISECOND,0);
Date monday = calendar.getTime();
return DateUtil.format(monday);
}
//返回周五日期字符串
public static String getFriday(){
Calendar calendar = Calendar.getInstance();
int dayWeek = calendar.get(Calendar.DAY_OF_WEEK);
if (1 == dayWeek) {
calendar.add(Calendar.DAY_OF_MONTH, -1);
}
// 设置一个星期的第一天,按中国的习惯一个星期的第一天是星期一
calendar.setFirstDayOfWeek(Calendar.MONDAY);
// 获得当前日期是一个星期的第几天
int day = calendar.get(Calendar.DAY_OF_WEEK);
int first = calendar.getFirstDayOfWeek();
// 计算周五的日期
calendar.add(Calendar.DAY_OF_WEEK, first - day +4);
return DateUtil.format(calendar.getTime());
}