WSTI

Date

Oct 1st, 2012
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. package javaapplication2;
  2. import java.util.Date;
  3.  
  4. public class JavaApplication2 {
  5.  
  6.     public static void main(String[] args) {
  7.    
  8.         Date data=new Date();                  
  9.         int godzina=data.getHours();
  10.         int minuta=data.getMinutes();
  11.         int sekunda=data.getSeconds();
  12.        
  13.         if (godzina < 10)
  14.             System.out.print("0" + godzina + ":");
  15.         else
  16.             System.out.print(godzina + ":");
  17.        
  18.         if (minuta < 10)
  19.             System.out.print("0" + minuta + ":");
  20.         else
  21.             System.out.print(minuta + ":");
  22.        
  23.         if (sekunda < 10)
  24.             System.out.print("0" + sekunda + ":");
  25.         else
  26.             System.out.println(sekunda);
  27.        
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment