Sample Programs

Sample java program to get last modification date of file

 package org.jusfortechies.example; 

 import java.io.File;
 import java.util.Date;
 
 public class FileLastModificationDate {

   public static void main(String[] args) {

      // Create an instance of file object.
      File file = new File("C:\\sample.txt");

      // Get the last modification date of the file.
      Long lastModified = file.lastModified();

      // The lastModified value returned above is in milliseconds
      // Convert it to Date
      Date date = new Date(lastModified);

      System.out.println(date);
   }

 }




blog comments powered by Disqus