// File: TestDate8.java (Module 8) // // Author: Rahul Simha // Created: October 6, 1998 // // Combining all the date classes. import java.util.*; import java.text.*; public class TestDate9 { public static void main (String[] argv) { // Create input and output patterns. SimpleDateFormat input_format = new SimpleDateFormat ("yyyy MMMM dd"), output_format = new SimpleDateFormat ("EEEE, MMM dd, yyyy, HH mm ss"); try { // Provide a format for input. Date d1 = input_format.parse ("1998 October 06"); System.out.println ("Date: " + d1); // Next, wrap a Calendar around a date. GregorianCalendar cal = (GregorianCalendar) input_format.getCalendar(); // Make changes as desired. cal.set (Calendar.HOUR_OF_DAY, 17); cal.set (Calendar.MINUTE, 22); cal.set (Calendar.SECOND, 35); // Get back the date. d1 = cal.getTime(); // Format the output. String s = output_format.format (d1); // Print. System.out.println (s); } catch (ParseException e) { System.out.println (e); } } }