Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Time1Test
- {
- public static void main ( String[] args )
- {
- //create and initialize a Time1 object
- Time1 time = new Time1(); // invokes Time1 constructor
- //output string representation of the time
- System.out.print( "The initial universal time is: ");
- System.out.println( time.toUniversalString() );
- System.out.print( "The initial universal time is: ");
- System.out.println( time.toString() );
- System.out.println(); //output a blank line
- //change time and output update time
- time.setTime( 13, 27, 6 );
- System.out.print( "Universal time after setTime is: " );
- System.out.println( time.toUniversalString() );
- System.out.print( "Standard time after setTime is: " );
- System.out.println( time.toString() );
- System.out.println(); //output a blank line
- //attemps to set time with invalid values
- try
- {
- time.setTime( 99, 99, 99); //all values out of range
- } //end try
- catch ( IllegalArgumentException e )
- {
- System.out.printf( "Exception: %s\n\n", e.getMessage() );
- } //end catch
- //display time after attempt to set invalid values
- System.out.println( "After attempting invalid settings:" );
- System.out.print( "Unversal time: ");
- System.out.println( time.toUniversalString() );
- System.out.print( "Standart time: " );
- System.out.println( time.toString() );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement