fork(5) download
  1. import java.time.LocalDate;
  2. import java.time.temporal.WeekFields;
  3. import java.util.Locale;
  4.  
  5. public class Main {
  6. public static void main(String[] args) {
  7. // Test
  8. int weekNumber = 34;
  9. int year = 2021;
  10.  
  11. System.out.println(getFirstDayOfWeek(year, weekNumber, Locale.UK));
  12. System.out.println(getFirstDayOfWeek(year, weekNumber, Locale.US));
  13. }
  14.  
  15. static LocalDate getFirstDayOfWeek(int year, int weekNumber, Locale locale) {
  16. return LocalDate
  17. .of(year, 2, 1)
  18. .with(WeekFields.of(locale).getFirstDayOfWeek())
  19. .with(WeekFields.of(locale).weekOfWeekBasedYear(), weekNumber);
  20. }
  21. }
Success #stdin #stdout 0.13s 52108KB
stdin
Standard input is empty
stdout
2021-08-23
2021-08-15