Home Java Java-get-example Get Time Stamp
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Get Time Stamp

Advertisement
In the example given below we will learn how to display current time. getTime() method returns the number of milliseconds represented by Date object that will be used as argument to create object of java.sql.Time class.

Get Time Stamp

     

In the example given below we will learn how to display current time. getTime() method returns the number of milliseconds represented by Date object that will be used as argument to create object of java.sql.Time class.

 

 

 

 

Here is the code:

public class GetTimeStamp {

  public static void main(String[] args) {
  java.util.Date time = new java.util.Date();
  System.out.println(new java.sql.Time(time.getTime())); 
  }
}

 

Output will be displayed as:


Download Source Code

 

Advertisements

Liked it!  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.

Posted on: October 23, 2008

Ask Questions?    Discuss: Get Time Stamp  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
Joe
November 12, 2011
Thanks

Thanks
pooja
March 21, 2012
Query

hello sir/madam, I have one problem please help me anyone I have hard code date in my java code for 1 min to 8 hours with 6 currency pairs like java.sql.Timestamp timestamp = Timestamp.valueOf(“2012-02-24 20:00:00?); then its working fine. If i have add for live chart like java.sql.Timestamp timestamp = new Timestamp(System.currentTimeMillis()); or java.util.Date date= new java.util.Date(); java.sql.Timestamp timestamp = new Timestamp(today.getTime()); then its taking lot of time to plot the jfreechart graph . so give me some suggestion or any commands need to add in my java code. Its urgent please.
DMCA.com