// Apollo11.java Copyright (c) Kari Laitinen // http://www.naturalprogramming.com // 2014-12-30 File created. // 2014-12-30 Last modification. // This program is a standard version of my textbook program Columbus.java. // With the new standard LocalDate class it is possible to calculate // chronological distances in years, months, and days. // To compile and run, this program needs JDK 8 or a later version. import java.time.* ; class Apollo11 { public static void main( String[] not_in_use ) { LocalDate date_of_discovery_of_america = LocalDate.of( 1492, 10, 12 ) ; LocalDate date_of_first_moon_landing = LocalDate.of( 1969, 7, 20 ) ; System.out.printf( "\n Christopher Columbus discovered America on %1$tF" + "\n That was a %1$tA\n", date_of_discovery_of_america ) ; System.out.printf( "\n Apollo 11 landed on the moon on %1$tF" + "\n That was a %1$tA\n", date_of_first_moon_landing ) ; Period distance_between = date_of_discovery_of_america.until( date_of_first_moon_landing ) ; System.out.print( "\n\n America was discovered " + distance_between.getYears() + " years, " + distance_between.getMonths() + " months, and " + distance_between.getDays() + " days" + "\n before the first moon landing.\n" ) ; } }