// BirthdaysWithDateISO.java Copyright (c) 2006 Kari Laitinen // http://www.naturalprogramming.com // 2006-02-15 File created. // 2006-02-15 Last modification. // This program was used to test DateISO.java // DateISO.java and DateDistance.java must be in the same folder // during compilation. // This program does not work if the given birthday is a leap day // i.e. 29th of February. import java.util.* ; class BirthdaysWithDateISO { public static void main( String[] not_in_use ) { Scanner keyboard = new Scanner( System.in ) ; System.out.print( "\n Type in your date of birth as DD.MM.YYYY" + "\n or MM/DD/YYYY or YYYY-MM-DD : " ) ; String date_of_birth_as_string = keyboard.nextLine() ; DateISO date_of_birth = new DateISO( date_of_birth_as_string ) ; System.out.print( "\n You were born on a " + date_of_birth.get_day_of_week() + "\n Here are your days to celebrate. You are\n" ) ; int years_to_celebrate = 10 ; while ( years_to_celebrate < 80 ) { DateISO date_to_celebrate = new DateISO( date_of_birth.day(), date_of_birth.month(), date_of_birth.year() + years_to_celebrate, date_of_birth.get_date_print_format() ) ; System.out.print( "\n " + years_to_celebrate + " years old on " + date_to_celebrate + " (" + date_to_celebrate.get_day_of_week() + ")" ) ; years_to_celebrate = years_to_celebrate + 10 ; } date_of_birth.set_date_print_format( 'I' ) ; if ( date_of_birth.is_in_year_of( new DateISO( 1, 1, 2002 ) ) ) { System.out.print( "\n\n " + date_of_birth + " belongs to year 2002 " ) ; } else { System.out.print( "\n\n " + date_of_birth + " does not belong to year 2002 " ) ; } if ( date_of_birth.is_in_month_of( new DateISO( 1, 2, 2004 ) ) ) { System.out.print( "\n\n " + date_of_birth + " belongs to February 2004 " ) ; } else { System.out.print( "\n\n " + date_of_birth + " does not belong to February 2004 " ) ; } } }