Monday, 21 July 2014

Java Program to Print Date And Time

  1. import java.util.*;
  2. class GetCurrentDateAndTime
  3. {
  4. public static void main(String args[])
  5. {
  6.  System.out.println("Welcome To Date/Time by kidshelp & Computerwizardi");
  7. int day, month, year;
  8. int second, minute, hour;
  9. GregorianCalendar date = new GregorianCalendar();
  10. day = date.get(Calendar.DAY_OF_MONTH);
  11. month = date.get(Calendar.MONTH);
  12. year = date.get(Calendar.YEAR);
  13. second = date.get(Calendar.SECOND);
  14. minute = date.get(Calendar.MINUTE);
  15. hour = date.get(Calendar.HOUR);
  16. System.out.println("Current date is "+day+"/"+(month+1)+"/"+year);
  17. System.out.println("Current time is "+hour+" : "+minute+" : "+second);
  18. }
  19. }

1 comment:

  1. I am flabbergasted with the amount of information i have been able to scoop from this article. thanks fotr sharing as i look forward to your next article.

    ReplyDelete

Breaking