How to get dates of a week (I know week number)?

后端 未结 5 2001
猫巷女王i
猫巷女王i 2020-12-01 11:16

I know the week number of the year, a week is start from Sunday, then Monday, Tuesday...,Saturday.

Since I know the week number, what\'s the efficient way to get the

5条回答
  •  鱼传尺愫
    2020-12-01 11:33

    If you don't want external library, just use calendar.

    SimpleDateFormat sdf = new SimpleDateFormat("MM dd yyyy");
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.WEEK_OF_YEAR, 23);        
    cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
    System.out.println(sdf.format(cal.getTime()));    
    

提交回复
热议问题