The code looks like this:
LocalDate.of(year,1,1).with(WeekFields.of(Locale.ENGLISH).weekOfWeekBasedYear(),weekNumber).with(DayOfWeek.MONDAY)
But when I count 49 weeks for this year, which is 2023, time always returns to 2023-11-27, and I actually think it should return 2023-12-04.
I was very confused and therefore I did a lot of tests
Finally, I let the program output the first week of the year,
When I use LocalDate.of(2023, 1, 1), the output is 2022-12-26 But When I use LocalDate.of(2023, 1, 2), the output is 2023-12-04
I began to understand the design. For this reason, I had to use java.util.Calendar for this function
My question is is there a better way to solve this problem?
As per the documentation of weekOfWeekBasedYear:
If you put the year as LocalDate.of(2023,1,1) it counts it as the last week of last year since the first day of this year is a sunday (not monday)