1/*2 * DateClient1.java3 *4 * A sample client program for the Date class.5 * 6 * Do not open this file until you have completed parts 1-5.7 */8public class DateClient1 {9 public static void main(String[] args) {10 /*** part 2 ***/11 /*** Note: These methods are static, so we call them using the class name. ***/12 boolean leap2010 = Date.isLeapYear(2010);13 System.out.println("is 2010 a leap year?: " + leap2010);14 System.out.println("is 1900 a leap year?: " + Date.isLeapYear(1900));15 System.out.println("is 2000 a leap year?: " + Date.isLeapYear(2000));16 System.out.println("is 2008 a leap year?: " + Date.isLeapYear(2008));17 System.out.println();18 int decDays = Date.numDaysInMonth(12, 2010);19 System.out.println("Dec. has " + decDays + " days");20 System.out.println("Feb. 2011 has " + Date.numDaysInMonth(2, 2011) + " days");21 System.out.println("Feb. 2012 has " + Date.numDaysInMonth(2, 2012) + " days");22 System.out.println();23 24 /*** parts 3, 4, and 5 ***/25 Date d = new Date(11, 28, 2013);26 System.out.println("Thanksgiving is on " + d); // toString will be called27 int mon = d.getMonth();28 System.out.println(" month: " + mon);29 int day = d.getDay();30 System.out.println(" day: " + day);31 int year = d.getYear();32 System.out.println(" year: " + year); 33 System.out.println(" month name: " + d.monthName()); 34 System.out.println("day of week name: " + d.dayOfWeekName());35 System.out.println();36 37 System.out.println("Creating three other Date objects:");38 Date d1 = new Date(7, 4, 1776);39 System.out.println("d1 = " + d1);40 Date d2 = new Date(9, 11, 2001);41 System.out.println("d2 = " + d2);42 Date d3 = new Date(1, 31, 2014);43 System.out.println("d3 = " + d3);44 System.out.println();45 46 // Try to create an invalid date.47 System.out.println("Trying to create a Date for February 30, 2012...");48 try {49 Date d4 = new Date(2, 30, 2012);50 System.out.println("The required exception was not thrown.");51 } catch(Exception e) {52 System.out.println("The required exception was thrown.");53 }54 System.out.println();55 }56}