Advertisement
lamaulfarid

ThisTest

Oct 14th, 2020
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. /**
  2.  * Write a description of class ThisTest here.
  3.  *
  4.  * @author Ahmad Lamaul Farid
  5.  * @version 08 Oktober 2020
  6.  */
  7. public class ThisTest
  8. {
  9.     public static void main( String[] args )
  10.     {
  11.         SimpleTime time = new SimpleTime( 15, 30, 19 );
  12.         System.out.println( time.buildString() );
  13.     }
  14. }
  15.  
  16. class SimpleTime
  17. {
  18.     private int hour;
  19.     private int minute;
  20.     private int second;
  21.    
  22.     public SimpleTime( int hour, int minute, int second )
  23.     {
  24.        this.hour = hour;
  25.        this.minute = minute;
  26.        this.second = second;
  27.     }
  28.    
  29.     public String buildString()
  30.     {
  31.        return String.format( "%24s: %s\n%24s: %s",
  32.            "this.toUniversalString()", this.toUniversalString(),
  33.            "toUniversalString()", toUniversalString() );
  34.     }
  35.    
  36.     public String toUniversalString()
  37.     {
  38.        return String.format( "%02d:%02d:%02d",
  39.           this.hour, this.minute, this.second );
  40.     }
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement