Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- 10
- 11 // output string representations of the time
- 12 System.out.print( "The initial universal time is: " );
- 13 System.out.println( );
- 14 System.out.print( "The initial standard time is: " );
- 15 System.out.println( );
- 16 System.out.println(); // output a blank line
- 17
- 18 // change time and output updated time
- 19
- 20 System.out.print( "Universal time after setTime is: " );
- 21 System.out.println( );
- 22 System.out.print( "Standard time after setTime is: " );
- 23 System.out.println( );
- 24 System.out.println(); // output a blank line
- 25
- 26 // attempt to set time with invalid values
- 27 try
- 28 {
- 29
- 30 } // end try
- 31 catch ( IllegalArgumentException e )
- 32 {
- 33 System.out.printf( "Exception: %s\n\n", e.getMessage() );
- 34 } // end catch
- 35
- 36 // display time after attempt to set invalid values
- 37 System.out.println( "After attempting invalid settings:" );
- 38 System.out.print( "Universal time: " );
- 39 System.out.println( );
- 40 System.out.print( "Standard time: " );
- 41 System.out.println( );
- 42 } // end main
- 43 } // end class Time1Test
- The initial universal time is: 00:00:0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement