Source of Time1PackageTest.java


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