Example of Date class

This section, you will learn how to create the current date.

Example of Date class


We can use Date class to use current date. In this program we are creating a Date object and by using it we are going to display the current date and time. It implements Serializable, Cloneable, Comparable interfaces. Its known subclasses are Date, Time, Timestamp




Code of a program is given below: 

import java.util.*;

public class  DateDemo{
  public static void main(String[] args) {
  Date d=new Date();
  System.out.println("Today date is "+ d);

Output of this program is given below:

Today date is Tue Dec 19 22:14:46 GMT+05:30 2006

Download this example

Share on Google+Share on Google+

Example of Date class

Posted on: June 7, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: Example of Date class   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
October 21, 2011

develop a java prg date should be 21/10/2011 this format and from the keyboard and store to emp table
March 20, 2012
Re:requesting for code

Thanks, I want the code for date, which should be displayed in web page using netbean as ide.
jd durga
August 28, 2012

how to get date from user
October 7, 2012
program prardigm

program for constructur using both default and parameter comstructure
November 21, 2012
reg-string conversion

respected sir/madam, i have on doubt regarding the string conversion for dates..i am creating the android application.now i have a code for displaying date using javascript.then i written my json data value in my localhost using if & else if function..these else if function contains data for 7 from the current date.its means currentdate,currentdate-1,currentdate-2,....currentdate-6.now i have to compare my phonegap date and local host date using string function.when those string are equal the appropriate set of date data will displaying in a table,,please give some idea about my doubt.any