Easy Tutorial
❮ Java Object Class Java Object Hashcode ❯

Java Example - Get Directory Last Modified Time

Java Example

The following example demonstrates how to use the file.lastModified() method of the File class to get the last modified time of a directory:

Main.java File

import java.io.File;
import java.util.Date;

public class Main {
    public static void main(String[] args) {
        File file = new File("C://FileIO//demo.txt");
        System.out.println("Last modified time: " + new Date(file.lastModified()));
    }
}

The output of the above code is:

Last modified time: Fri Apr 10 11:09:19 CST 2015

Java Example

❮ Java Object Class Java Object Hashcode ❯