File Last Modified Date Java Program

Sharing is healthy !!

In the following example you will learn how to get the File Last Modified Date Java Program. Here we will be using file.lastModified() to get the last modified date and time of a file. Let’s see the code implementation,

File Last Modified Date Java Program

Read Also – Date Time Java Program

Example: To get the File Last Modified Date Java Program

import java.io.*;
import java.util.Date;
import java.text.SimpleDateFormat;

public class Last_Modified_Date_Time {

public static void main(String[] args) {

File file = new File("C:\\modified_File.txt");
System.out.println("Before file format : " + file.lastModified());
SimpleDateFormat sim = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
System.out.println("After file format : " + sim.format(file.lastModified()));
}
}

Output:

Before file format : 1486480590836
After file format : 02/07/2014 05:14:10

Sharing is healthy !!

Leave a Reply

Your email address will not be published.