/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; import java.time.* ; /* Name of the class has to be "Main" only if the class is public. */ class Ideone { { LocalDate startOfYear = Year.of( 2019 ).atDay( 1 ); // Determine first day of the year. LocalDate startOfFollowingYear = startOfYear.plusYears( 1 ); LocalDate localDate = startOfYear; while ( localDate.isBefore( startOfFollowingYear ) ) { if ( localDate.getDayOfWeek().equals( DayOfWeek.TUESDAY ) ) { tuesdays.add( localDate ); } // Set up the next loop. localDate = localDate.plusDays( 1 ); } } }
Standard input is empty
[2019-01-01, 2019-01-08, 2019-01-15, 2019-01-22, 2019-01-29, 2019-02-05, 2019-02-12, 2019-02-19, 2019-02-26, 2019-03-05, 2019-03-12, 2019-03-19, 2019-03-26, 2019-04-02, 2019-04-09, 2019-04-16, 2019-04-23, 2019-04-30, 2019-05-07, 2019-05-14, 2019-05-21, 2019-05-28, 2019-06-04, 2019-06-11, 2019-06-18, 2019-06-25, 2019-07-02, 2019-07-09, 2019-07-16, 2019-07-23, 2019-07-30, 2019-08-06, 2019-08-13, 2019-08-20, 2019-08-27, 2019-09-03, 2019-09-10, 2019-09-17, 2019-09-24, 2019-10-01, 2019-10-08, 2019-10-15, 2019-10-22, 2019-10-29, 2019-11-05, 2019-11-12, 2019-11-19, 2019-11-26, 2019-12-03, 2019-12-10, 2019-12-17, 2019-12-24, 2019-12-31]