In this tutorial, I am attaching simple program about Get File Last Modified Date in Java.
We can able to get the last modified date of the file using Java program. In order to do that we may have to invoke the predefined method called lastModified(). Which is belongs to java.io.File class. It will return the long value. that can be passed as argument of java.util.Date constructor then we can get the Date Object for further usage. The sample program were attached below.
GetModifiedDate.java
package com.dineshkrish.files; import java.io.File; import java.util.Date; /** * * @author Dinesh Krishnan * */ public class GetModifiedDate { public static void main(String[] args) { // Defining the File Object File file = new File("C:\\example.txt"); long lastModified = file.lastModified(); // Creating Date Object using long(ie: lastModified) value Date lastModifiedDate = new Date(lastModified); // Printing the Result System.out.println(lastModifiedDate); } }
Output
——————
Wed Oct 19 17:35:55 IST 2015
More from my site

Hello, folks, I am a founder of idineshkrishnan.com. I love open source technologies, If you find my tutorials are useful, please consider making donations to these charities.
No responses yet