Convert Date into milliseconds example

  1. /*
  2.   Convert Date into milliseconds example
  3.   This example shows how to get the milliseconds since January 1, 1970, 00:00:00 GMT
  4.   represented by this Date object, using getTime() method of java Date class
  5. */
  6.  
  7. import java.util.*;
  8.  
  9. public class ConvertDateIntoMilliSecondsExample{
  10.  
  11. public static void main(String args[]){
  12.  
  13. //create a Date object
  14. Date date = new Date();
  15. System.out.println("Date is : " + date);
  16.  
  17. //use getTime() method to retrieve milliseconds
  18. System.out.println("Milliseconds since January 1, 1970, 00:00:00 GMT : "
  19. + date.getTime());
  20.  
  21. }
  22.  
  23. }
  24.  
  25. /*
  26. TYPICAL Output would be
  27. Date is : Sun Sep 09 19:56:42 EDT 2007
  28. Milliseconds since January 1, 1970, 00:00:00 GMT : 1189382202606
  29. */

post something usfully

Anyone can print the milliseconds. Please post something that converts milliseconds to the current time formatted in HH:MM:SS

Post new comment

To combat spam, please enter the code in the image.


Suggested Reading

Oracle Magazine
Contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more.
Cost: FREE

View/Subscribe
NASA Tech Briefs
Features exclusive reports of innovations developed by NASA and its industry partners/contractors that can be applied to develop new/improved products and solve engineering or manufacturing problems.
Cost: FREE

View/Subscribe
FierceBiotech IT
Is a free, easy to read weekly email service that brings must read biotech IT news to senior biotech, pharma, and IT executives.
Cost: FREE

View/Subscribe
Simply SQL
Simply SQL is a practical step-by-step guide to writing SQL.
Cost: FREE

View/Subscribe
Simply JavaScript
Packed with full-color examples, Simply JavaScript is all you need to start programming in JavaScript the right way.
Cost: FREE

View/Subscribe
PCMag.com's What's New Now
Lance Ulanoff, Editor in Chief of the PC Magazine Network, brings you this twice-weekly roundup of the latest top tech stories, the best new product reviews, plus special offers from Ziff Davis and its partners.
Cost: FREE

View/Subscribe

Could not find what you are looking for? Search Java Examples




Feel Tired? Read Jokes & Inspirational Stories, Play Games!