tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Java > IO > Set Last Modified Date

Set Last Modified Date 

The following example shows how to set the last modified date of a file.

File Name  :  
com/bethecoder/tutorials/io/SetLastModifiedTest.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.io;

import java.io.File;
import java.util.Date;

public class SetLastModifiedTest {

  /**
   @param args
   */
  public static void main(String[] args) {

    File file = new File("C:\\file_ops.txt");
    System.out.println(file + " is last modified on " new Date(file.lastModified()));
    
    file.setLastModified(new Date(15011).getTime());
    System.out.println(file + " is last modified on " new Date(file.lastModified()));
  }

}
   

It gives the following output,
C:\file_ops.txt is last modified on Thu May 05 11:23:10 IST 2011
C:\file_ops.txt is last modified on Tue Feb 01 00:00:00 IST 2050



 
  


  
bl  br