取得指定日期所在月的1号所在周的Sunday(可能是上个月的日期)
比如:
指定日期:2007-3-17
所求日期:2007-2-25

解决方案 »

  1.   

    String s = "2007-3-17";
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date date=new Date();
    try {
    date = sdf.parse(s);
    } catch (ParseException e) {
    e.printStackTrace();
    }
         Calendar calendar = Calendar.getInstance();
     calendar.setTime(date);
     calendar.get(calendar.MONTH);
             calendar.set(calendar.WEEK_OF_MONTH, 1);
             calendar.set(calendar.DAY_OF_WEEK, 1);
     System.out.println(sdf.format(calendar.getTime()));
    除了这样 还有什么好方法吗