adsense


Monday, 16 November 2015

JAVA PROGRAM TO DISPLAY DATE AND TIME, PRINT DATE AND TIME USING JAVA PROGRAM PAGE 31








COMPUTER LANGUAGES HTML,C,C++.JAVA,.NET AND MULTIMEDIA basics and programs click home button



JAVA PROGRAM TO DISPLAY DATE AND TIME, PRINT DATE AND TIME USING JAVA PROGRAM







Java program to display date and time, print date and time using java program


Java date and time program :- Java code to print or display current system date 
and time. This program prints current date and time. We are using GregorianCalendar 
class in our program. Java code to print date and time is given below :-

Java programming code

import java.util.*;
 
class GetCurrentDateAndTime
{
   public static void main(String args[])
   {
      int day, month, year;
      int second, minute, hour;
      GregorianCalendar date = new GregorianCalendar();
 
      day = date.get(Calendar.DAY_OF_MONTH);
      month = date.get(Calendar.MONTH);
      year = date.get(Calendar.YEAR);
 
      second = date.get(Calendar.SECOND);
      minute = date.get(Calendar.MINUTE);
      hour = date.get(Calendar.HOUR);
 
      System.out.println("Current date is  "+day+"/"+(month+1)+"/"+year);
      System.out.println("Current time is  "+hour+" : "+minute+" : "+second);
   }
}


No comments: