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