Source of Time1Test.java


  1: // Fig. 8.2: Time1Test.java
  2: // Time1 object used in an application.
  3: 
  4: public class Time1Test 
  5: {
  6:    public static void main( String args[] )
  7:    {
  8:       // create and initialize a Time1 object
  9:       Time1 time = new Time1(); // invokes Time1 constructor
 10: 
 11:       // output string representations of the time
 12:       System.out.print( "The initial universal time is: " );
 13:       System.out.println( time.toUniversalString() );
 14:       System.out.print( "The initial standard time is: " );
 15:       System.out.println( time.toString() );
 16:       System.out.println(); // output a blank line
 17: 
 18:       // change time and output updated time 
 19:       time.setTime( 13, 27, 6 ); 
 20:       System.out.print( "Universal time after setTime is: " );
 21:       System.out.println( time.toUniversalString() );
 22:       System.out.print( "Standard time after setTime is: " );
 23:       System.out.println( time.toString() );
 24:       System.out.println(); // output a blank line
 25: 
 26:       // set time with invalid values; output updated time 
 27:       time.setTime( 99, 99, 99 ); 
 28:       System.out.println( "After attempting invalid settings:" );
 29:       System.out.print( "Universal time: " );
 30:       System.out.println( time.toUniversalString() );
 31:       System.out.print( "Standard time: " );
 32:       System.out.println( time.toString() );
 33:    } // end main
 34: } // end class Time1Test
 35: 
 36: 
 37: /**************************************************************************
 38:  * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and               *
 39:  * Pearson Education, Inc. All Rights Reserved.                           *
 40:  *                                                                        *
 41:  * DISCLAIMER: The authors and publisher of this book have used their     *
 42:  * best efforts in preparing the book. These efforts include the          *
 43:  * development, research, and testing of the theories and programs        *
 44:  * to determine their effectiveness. The authors and publisher make       *
 45:  * no warranty of any kind, expressed or implied, with regard to these    *
 46:  * programs or to the documentation contained in these books. The authors *
 47:  * and publisher shall not be liable in any event for incidental or       *
 48:  * consequential damages in connection with, or arising out of, the       *
 49:  * furnishing, performance, or use of these programs.                     *
 50:  *************************************************************************/