Example & Tutorial understanding programming in easy ways.

How to get file last modified time in java?.

Sometimes we need to get the file last modified date in java, usually for listeners like JBoss config file changes hot deployment. java.io.File class lastModified() returns last modified date in long, we can construct date object for this time.

Example:

package javatest;

import java.io.File;

import java.util.Date;

public class FileDatetest {

public static void main(String[] args) {

File file = new File("student.txt");

long timestamp = file.lastModified();

System.out.println("student.txt last modified date = "+new Date(timestamp));

}

Read More →