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

后端 未结 5 1999
猫巷女王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:39

    This answer is pretty much same as others. But, here it goes:

    int year = 2018;
    int week = 27;
    int day = 1; //assuming week starts from sunday
    Calendar calendar = Calendar.getInstance();
    calendar.setWeekDate(year, week, day);
    System.out.println(calendar.getTime());
    

提交回复
热议问题