import java.text.SimpleDateFormat;
import java.util.Date;
public class ConvertMillisecondToDate {
public static void main(String[] args) throws Exception {
SimpleDateFormat sdf =
new SimpleDateFormat( "dd-MM-yyyy hh:mm:ss.SSS");
// Get current time in milliseconds
Long milliSec = System.currentTimeMillis();
System.out.println("MilliSec : "+ milliSec);
Date date = new Date(milliSec);
System.out.println("Date : "+ sdf.format(date));
}
}
Output:
MilliSec : 1328990835987
Date: 12-02-2012 01:37:15.987