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 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.

package com.dineshkrish.files;
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



Wed Oct 19 17:35:55 IST 2015


No responses yet

Leave a Reply

Your email address will not be published. Required fields are marked *