Answers for "how to get date of last modification for a file java"

1

How to get file last modified date in java

import java.io.*;
import java.util.Date;
import java.text.SimpleDateFormat;
public class LastModifiedDateDemo
{
   public static void main(String[] args)
   {
      File file = new File("d:\\modifiedFile.txt");
      System.out.println("Before - file last modified date: " + file.lastModified());
      SimpleDateFormat sim = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
      System.out.println("After - file last modified date: " + sim.format(file.lastModified()));
   }
}
Posted by: Guest on January-01-2021

Code answers related to "how to get date of last modification for a file java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language