java根据年份和周数,获取前后时间

    public String getWeekDays(Integer year,Integer week){
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
        Calendar cal=Calendar.getInstance();
        cal.setFirstDayOfWeek(Calendar.MONDAY);
        cal.set(Calendar.YEAR, year);
        cal.set(Calendar.WEEK_OF_YEAR, week);
        cal.set(Calendar.DAY_OF_WEEK, cal.getFirstDayOfWeek());
        String beginDate = sdf.format(cal.getTime());
        cal.add(Calendar.DAY_OF_WEEK, 7);
        String endDate = sdf.format(cal.getTime());
        return beginDate+"至"+endDate;
    }

 

你可能感兴趣的:(java根据年份和周数,获取前后时间)