how to get file last modified date in java

Solutions on MaxInterview for how to get file last modified date in java by the best coders in the world

showing results for - "how to get file last modified date in java"
Marlene
29 May 2020
1import java.io.*;
2import java.util.Date;
3import java.text.SimpleDateFormat;
4public class LastModifiedDateDemo
5{
6   public static void main(String[] args)
7   {
8      File file = new File("d:\\modifiedFile.txt");
9      System.out.println("Before - file last modified date: " + file.lastModified());
10      SimpleDateFormat sim = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
11      System.out.println("After - file last modified date: " + sim.format(file.lastModified()));
12   }
13}
Emy
05 Apr 2020
1Path file = ...;
2BasicFileAttributes attr = Files.readAttributes(file, BasicFileAttributes.class);
3
4System.out.println("creationTime: " + attr.creationTime());
5System.out.println("lastAccessTime: " + attr.lastAccessTime());
6System.out.println("lastModifiedTime: " + attr.lastModifiedTime());
queries leading to this page
how to get date of last modification for a file javacreatin file date javajava java io file get creation datejava get file last modified timefile last modified to date javajava file get date modifiedjava create file name date nowhow do i get the date from a file that just got created to a java fileget created date of file javacheck last modified time of a file on server using javajava get file creation datejava get file date createdhow to find file creation date in javashow last modified files in javajava file get created datejava get creation datehow to get modified time of a file in javaget creation date file javalast modified date of a file in javahow to read date from a file in javaget last modified date of folder javaget last modified file from directory javahow to get file date in javalast modified file javajava get creation date of filefind the last modified file in javaget last date of modification of file in javahow to get file last modified date in javajava date of creationjava creation datefunction creation time javafilename with current date in javajava get date of file creationget arrived date from file object java 8last modified time of a file in javaget created at file javajava file last modified to datejava get file creation timecreation date of javajava get file creation date modified datejava file get last modified dateget a file time of creation javshow to get the last modified date of a file in javajava file last modifiedget date from filename javaget date created file javahow to know the creation date of a file javahow to get the modified date of file in javager creation date of file javahow to get the creation date of a file using javafile creationtime javaget file date javafile get modified date javahow to get file last modified date in java