Java Program:
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 |
package org.arpit.java2blog; import java.io.File; import java.text.SimpleDateFormat; public class GetLastModifiedTimeOfFileMain { public static void main(String[] args) { System.out.println("-----------------"); // Read the file File mp3File=new File("/Users/Arpit/Desktop/MySong.mp3"); System.out.println("Time inmilliseconds: "+mp3File.lastModified()); SimpleDateFormat sdf= new SimpleDateFormat("dd MMM yyyy HH:mm:sss"); String dateFormat=sdf.format(mp3File.lastModified()); System.out.println("Time in date format: "+dateFormat); System.out.println("-----------------"); } } |
1 2 3 4 5 6 |
----------------- Time in milliseconds: 1424326757000 Time in date format: 19 Feb 2015 11:49:017 ----------------- |