// Weddingdates.java (c) Kari Laitinen // http://www.naturalprogramming.com // 2004-10-06 File created. // 2014-12-30 The new standard Java class LocalDate was taken into use. import java.time.* ; class Weddingdates { public static void main( String[] not_in_use ) { LocalDate date_to_increment = LocalDate.now() ; int number_of_dates_printed = 0 ; System.out.print( "\n These are easy-to-remember dates for weddings and" + "\n other important events because the days and months" + "\n consist of the digits used in the year: \n" ) ; while ( number_of_dates_printed < 60 ) { String day_as_string = String.format( "%02d", date_to_increment.getDayOfMonth() ) ; String month_as_string = String.format( "%02d", date_to_increment.getMonth().getValue() ) ; String year_as_string = "" + date_to_increment.getYear() ; if ( year_as_string.indexOf( day_as_string.charAt( 0 ) ) != -1 && year_as_string.indexOf( day_as_string.charAt( 1 ) ) != -1 && year_as_string.indexOf( month_as_string.charAt( 0 ) ) != -1 && year_as_string.indexOf( month_as_string.charAt( 1 ) ) != -1 ) { // Now we have found a date that meets our requirements. if ( number_of_dates_printed % 5 == 0 ) { System.out.print( "\n" ) ; } System.out.print( " " + date_to_increment ) ; number_of_dates_printed ++ ; } // Here we create a new LocalDate object that contains the date of // the following day. date_to_increment = date_to_increment.plusDays( 1 ) ; } System.out.print( "\n\n" ) ; } } /* See WeddingdatesOriginal.java if you need to study the program that was shown in my original Java textbook. */