document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1.    /**
  2.  * Write a description of class time1 here.
  3.  *
  4.  * @author (Muhammad Bagus Istighfar)
  5.  * @version (14.10.20)
  6.  */
  7. public class Time1
  8. {
  9.     private int hours;
  10.     private int minute;
  11.     private int second;
  12.    
  13.     public void setTime (int h, int m, int s)
  14.     {
  15.         if ((h >= 0 && h<24) && (m>= 0 && m<60) && (s>=0 && s<60))
  16.         {
  17.             hours=h;
  18.             minute=m;
  19.             second=s;
  20.         }
  21.         else
  22.         {
  23.             throw new IllegalArgumentException(
  24.             "hour,minute and/pr second was out of range");
  25.         }
  26.     }
  27.     public String toUniversalString()
  28.     {
  29.         return String.format("%02d: %02d: %02d", hours,minute,second);
  30.     }
  31.     public String toString ()
  32.     {
  33.         return String.format("%d:%02d:%02d %s",
  34.         (( hours == 0 || hours==12) ?12 : hours%12),minute , second,
  35.         (hours<12 ? "AM" : "PM"));
  36.     }
  37. }
  38.  
  39.  
');