Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Getting time in Milliseconds 
 

In the previous examples of Date class we have created simple Date and now in this section we are going to get the current date and time in the milliseconds. To do this we have used getTime() method of Date class.

 

Getting time in Milliseconds

                         

In the previous examples of Date class we have created simple Date and now in this section we are going to get the current date and time in the milliseconds. To do this we have used getTime() method of Date class.

getTime() returns the total time in milliseconds since 1 January 1970 00:00:00 GMT. getTime() returns total time in long datatype.

Here is the full example code of GetTimeMilliseconds.java as follows:

GetTimeMilliseconds.java

import java.util.Date;

public class GetTimeMilliseconds{

  public static void main(String[] args) {
     // Create a new instance of Date
       Date newDate = new Date();
       System.out.println("New Date:="+newDate);
     // getTime() method returns number of milliseconds since Jan 1970
        System.out.println("Number of milliseconds ==>"+newDate.getTime());
  }
}

Compile this example with the javac command and execute it.

Output: 

C:\DateExample>javac GetTimeMilliseconds.java

C:\DateExample>java GetTimeMilliseconds
New Date:=Fri Oct 10 13:26:49 GMT+05:30 2008
Number of milliseconds ==>1223625409171

Download Source Code

                         

» View all related tutorials
Related Tags: java c class time calendar method arguments field this ai package ie example add with mount program ram exam span

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.