Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-05-2008, 11:10 AM
Moderator
 
Join Date: Nov 2007
Posts: 1,657
Java Tip will become famous soon enoughJava Tip will become famous soon enough
How to change the date of modification of a file
This code will change the last modified date of the file to the desired date.

Code:
import java.io.File; import java.util.Date; public class FileDtModificationExp { public static void main(String[] args) { File file = new File("C:\\MyFile.txt"); long modifiedTime = file.lastModified(); System.out.println(new Date(modifiedTime)); Date newModifiedDate = new Date("12/12/2006"); long newModifiedTime = newModifiedDate.getTime(); file.setLastModified(newModifiedTime); } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get the last modified date of a file from a java program Java Tip java.io 0 04-04-2008 03:45 PM
I have c++ code for LUDO Game, Can anyone change it to Java file - Please help me Bhanu Sagar AWT / Swing 0 03-12-2008 07:39 PM
How to find file created date..... roshithmca Advanced Java 1 02-18-2008 10:48 AM
Getting modification and expiration date of content Java Tip Java Tips 0 11-26-2007 02:20 PM
File creating date/time bugger New To Java 1 11-11-2007 08:43 PM


All times are GMT +3. The time now is 12:41 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org