document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1.  
  2. /**
  3. * Write a description of class timetest here.
  4. *
  5. * @author (your name)
  6. * @version (a version number or a date)
  7. */
  8. public class timetest
  9. {
  10. public static void main(String[] args)
  11. {
  12. //create and initialize a time1 object
  13. time1 time = new time1(); //invokes time1 constructor
  14.  
  15. //output string representation of the time
  16. System.out.print("The initial universal time is: ");
  17. System.out.println(time.toUniversalString());
  18. System.out.print("The initial standard time is: ");
  19. System.out.println(time.toString());
  20. System.out.println(); //output a blank line
  21.  
  22. //change time and output updated time
  23. time.setTime(19, 37, 20);
  24. System.out.print("Universal time after setTime is: ");
  25. System.out.println(time.toUniversalString());
  26. System.out.print("Standard time after setTime is: ");
  27. System.out.println(time.toString());
  28. System.out.println(); //output a blank line
  29.  
  30. //attempt to set time with invalid values
  31. try
  32. {
  33. time.setTime(99, 99, 99); //all values out of range
  34. } //end try
  35. catch(IllegalArgumentException e)
  36. {
  37. System.out.printf("Exception: %s\\n\\n", e.getMessage());
  38. } //end catch
  39.  
  40. //display time after attemot to set invalid values
  41. System.out.println("After attempting invalid settings:");
  42. System.out.print("Universal time: ");
  43. System.out.println(time.toUniversalString());
  44. System.out.print("Standard time: ");
  45. System.out.println(time.toString());
  46. } //end main
  47.  
  48. } //end class time1test
');