Share on Google+Share on Google+

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


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

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

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 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, 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