public static void main(String[] args) {
// 定义输出日期格式
SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-MM-dd”);
Date currentDate = null;
try {
currentDate = sdf.parse("2020-07-13");
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
List<Date> days = dateToWeek(currentDate);
System.out.println("今天的日期: " + sdf.format(currentDate));
for (Date date : days) {
System.out.println(sdf.format(date));
}
}
/**
* 根据日期获得所在周的日期
* @param mdate
* @return
*/
@SuppressWarnings("deprecation")
public static List<Date> dateToWeek(Date mdate) {
int b = mdate.getDay();
Date fdate;
List<Date> list = new ArrayList<Date>();
Long fTime = mdate.getTime() - b * 24 * 3600000;
for (int a = 1; a <=