// Friday13GregorianCalendar.java (c) 2005 Kari Laitinen // http://www.naturalprogramming.com // 2004-08-19 File created. // 2005-05-11 Last modification. // This program works almost like Friday13.java import java.util.* ; class Friday13GregorianCalendar { public static void main( String[] not_in_use ) { Calendar date_to_increment = new GregorianCalendar() ; int number_of_friday13_dates_to_print = 10 ; System.out.print( "\n The following are the next such dates" + "\n that are Fridays and the 13th days" + "\n of a month: \n" ) ; while ( number_of_friday13_dates_to_print > 0 ) { while ( date_to_increment.get( Calendar.DAY_OF_WEEK ) != Calendar.FRIDAY || date_to_increment.get( Calendar.DAY_OF_MONTH ) != 13 ) { date_to_increment.add( Calendar.DAY_OF_MONTH, 1 ) ; } System.out.printf( "\n %1$tF, %1$tA", date_to_increment ) ; date_to_increment.add( Calendar.DAY_OF_MONTH, 27 ) ; number_of_friday13_dates_to_print -- ; } } }