Source Code : Compare File Dates

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Compare File Dates

       
import java.io.File;

public class CompareFileDates {
  public static void main(String[] args) {
    // Get the timestamp from file 1
    String f1 = "run.bat";
    long d1 = new File(f1).lastModified();

    // Get the timestamp from file 2
    String f2 = "build.xml";
    long d2 = new File(f2).lastModified();

    String relation;
    if (d1 == d2)
      relation = "the same age as";
    else if (d1 < d2)
      relation = "older than";
    else
      relation = "newer than";
    System.out.println(f1 + " is " + relation +  + f2);
  }
}

           
         
    
    
    
    
    
    
  

Thank with us