document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. /**
  2.  * Write a description of class time1 here.
  3.  *
  4.  * @author (Aristya Vika)
  5.  * @version (12.10.20)
  6.  */
  7. public class Time1
  8. {
  9.     private int jam;
  10.     private int menit;
  11.     private int detik;
  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.             jam=h;
  18.             menit=m;
  19.             detik=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", jam,menit,detik);
  30.     }
  31.     public String toString ()
  32.     {
  33.         return String.format("%d:%02d:%02d %s",
  34.         (( jam == 0 || jam==12) ?12 : jam%12),menit, detik,
  35.         (jam<12 ? "AM" : "PM"));
  36.     }
  37. }
  38.    
');