Miliseconds to normal date

Put your problem here if it does not fit any of the other categories.

Miliseconds to normal date

Postby delph » Fri Mar 11, 2011 6:41 pm

Hey community :)
I would like to find out file creation date. As i discovered the way to do it is use file.lastModified()
The problem is this method return long value representing the time the file was last modified, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970).

I need to represent this time in normal dd/mm/yyyy - hh:mm:ss format.

Any suggestion regarding this issue ?
Code will be strongly appreciated :)
Posts: 8
Joined: Sat Feb 26, 2011 7:05 am


Re: Miliseconds to normal date

Postby Nomad0404 » Mon Mar 14, 2011 3:26 pm

In Java you do:

Code: Select all
import java.util.*;
import java.text.*;
public class MillisecondToDate {
   public static void main(String[] args)throws Exception {
     long yourmilliseconds = 1119193190;
SimpleDateFormat sdf = new SimpleDateFormat("MMM dd,yyyy HH:mm");

Date resultdate = new Date(yourmilliseconds);
System.out.println(sdf.format(resultdate));  }

Or something similar.

Junior Developer
Junior Developer
Posts: 19
Joined: Mon Mar 07, 2011 10:23 pm


Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 8 guests