上一周的周一和周日

上一周的周一和周日
上一周的周一和周日

Calendar cl = Calendar.getInstance();
  cl.getTime();
  cl.add(cl.DAY_OF_YEAR, -cl.get(cl.DAY_OF_WEEK)+1);//get previous Sunday
  System.out.println(cl.get(cl.YEAR) + "-" + (cl.get(cl.MONTH)+1) + "-"
  + cl.get(cl.DAY_OF_MONTH) +"week:"+(cl.get(cl.DAY_OF_WEEK)-1));
  
  cl.add(cl.DAY_OF_YEAR, -6 ); //get previous Monday
  System.out.println(cl.get(cl.YEAR) + "-" + (cl.get(cl.MONTH)+1) + "-"
  + cl.get(cl.DAY_OF_MONTH) +"week:"+(cl.get(cl.DAY_OF_WEEK)-1));

你可能感兴趣的:(上一周的周一和周日)