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

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

    Pure Java 8 / java.time solution

    Based on this:

    final long calendarWeek = 34;
    LocalDate desiredDate = LocalDate.now()
                .with(IsoFields.WEEK_OF_WEEK_BASED_YEAR, calendarWeek)
                .with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
    

提交回复
热议问题