// TitanicTimes.java (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 Titanic.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.* ; // for classes LocalDate, Period class TitanicTimes { public static void main( String[] not_in_use ) { LocalDate date_when_titanic_sank = LocalDate.of( 1912, 4, 15 ) ; LocalDate date_of_today = LocalDate.now() ; Period time_from_sinking = date_when_titanic_sank.until( date_of_today ) ; System.out.print( "\n Today it is " + date_of_today + ".\n On " + date_when_titanic_sank + ", the famous ship \"Titanic\" went to" + "\n the bottom of Atlantic Ocean." + "\n That happened " + time_from_sinking.getYears() + " years, " + time_from_sinking.getMonths() + " months, and " + time_from_sinking.getDays() + " days ago. \n\n" ) ; } }