如何获得指定周的起始日期和结束日期  比如 2006年第2周从 X月X日 ~ X月X日
如何考虑跨年问题

解决方案 »

  1.   

    calender类就可以解决,看一下sdk吧
      

  2.   

    //已知某年ryear 自然周rweek,计算该周的第一天对应的日期
                SimpleDateFormat temp_DateFormat = new SimpleDateFormat("yyyy-MM-dd");
                Calendar temp_cal1 = Calendar.getInstance();
                //只设置了年和周的field,生成的日历会以当前日期是星期几来设置日历的星期
                temp_cal1.set(Calendar.YEAR, Integer.valueOf(this.ryear)); 
                temp_cal1.set(Calendar.WEEK_OF_YEAR, Integer.valueOf(this.rweek)); 
                //减去星期几对应的数字,就会得出该周第一日(即星期天)对应的日期。如星期一对应了2,就减1天
                temp_cal1.add(Calendar.DAY_OF_MONTH, -(temp_cal1.get(Calendar.DAY_OF_WEEK))+1);//
                System.out.println(temp_DateFormat.format(temp_cal1.getTime()));
      

  3.   

    Calendar类里面有getFirstDayOfWeek()