|
@@ -57,10 +57,14 @@ public class DateUtil {
|
|
|
public static String getWeekStart(Date date){
|
|
|
Calendar cal=Calendar.getInstance();
|
|
|
cal.setTime(date);
|
|
|
- cal.add(Calendar.WEEK_OF_MONTH, 0);
|
|
|
- cal.set(Calendar.DAY_OF_WEEK, 2);
|
|
|
- Date time=cal.getTime();
|
|
|
- return new SimpleDateFormat(DAY_FORMAT).format(time);
|
|
|
+ int dayWeek = cal.get(Calendar.DAY_OF_WEEK);
|
|
|
+ if (1 == dayWeek) {
|
|
|
+ cal.add(Calendar.DAY_OF_MONTH, -1);
|
|
|
+ }
|
|
|
+ cal.setFirstDayOfWeek(Calendar.MONDAY);
|
|
|
+ int day = cal.get(Calendar.DAY_OF_WEEK);
|
|
|
+ cal.add(Calendar.DATE, cal.getFirstDayOfWeek() - day);
|
|
|
+ return new SimpleDateFormat(DAY_FORMAT).format(cal.getTime());
|
|
|
}
|
|
|
/**
|
|
|
* 获取上周周的第一天
|