Java8 gets Monday based on the week of the year

Java8 time parsing exception

knows a time string indicating the week ordinal of the year, such as 2018-48 , the 48th week of 2018. I want to use this string to get the time of Monday and Sunday of this week

.

related codes

//  2018-48
String format = LocalDate.now().format(DateTimeFormatter.ofPattern("YYYY-w"));
      
//  
LocalDate date = LocalDate.parse(format,DateTimeFormatter.ofPattern("YYYY-w"));

how should it be parsed?

Dec.27,2021

specify the day of the week

    int year = 2018;
    int week = 48;
    WeekFields weekFields = WeekFields.of(Locale.FRANCE);
    LocalDateTime monday = LocalDateTime.now()
            .withYear(year)
            .with(weekFields.weekOfYear(), week)
            .with(weekFields.dayOfWeek(), 1L);
Menu