Showing posts with label date in java. Show all posts
Showing posts with label date in java. Show all posts

Saturday, May 6, 2017

Display Date and Time in Java

Here is a very simple program that I wrote using Java as my programming language to display the current date and time from the users computer. The code is very easy to understand it uses java core API to retrieve the current date and time. I hope you will find my work useful in learning Java programming. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing

Demo.java

/* Written By: Jake R. Pomperada, MAED-IT           */
/* Language  : Java                                                  */
/* Date      : May 6, 2017                                        */

package demo;


import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;


public class Demo {

public static void main(String[] args) {
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
Date date = new Date();
System.out.print("\n\n");
System.out.print("\t Display Date and Time in Java ");
System.out.print("\n\n");
System.out.println("Today is " + dateFormat.format(date) + "."); 
}

}