/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; import java.time.* ; import java.util.stream.* ; import java.time.temporal.* ; /* Name of the class has to be "Main" only if the class is public. */ class Ideone { { List< LocalDate > firstSundayOfEachMonthInYear = Stream.of( Month.values() ) .map( month -> Year .of( 2021 ) .atMonth( month ) .atDay( 1 ) .with( TemporalAdjusters.firstInMonth( DayOfWeek.SUNDAY ) ) ) .collect( Collectors.toList() ) ; } }
Standard input is empty
[2021-01-03, 2021-02-07, 2021-03-07, 2021-04-04, 2021-05-02, 2021-06-06, 2021-07-04, 2021-08-01, 2021-09-05, 2021-10-03, 2021-11-07, 2021-12-05]