java计算当前周开始日期&结束日期
1 public static Date getFirstDayOfWeek(Date date) { 2 Calendar c = new GregorianCalendar(); 3 c.setFirstDayOfWeek(Calendar.MONDAY); 4 c.setTime(date); 5 c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek()); // Monday 6 return c.getTime(); 7 } 8 9 10 public static Date getLastDayOfWeek(Date date) { 11 Calendar c = new GregorianCalendar(); 12 c.setFirstDayOfWeek(Calendar.MONDAY); 13 c.setTime(date); 14 c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek() + 6); // Sunday 15 return c.getTime(); 16 }