Is there any way to change a file’s last modification time from Java?
It is not possible to alter the time of last modification in Java version before the 1.2 JDK. One of the new features introduced to
java.io.File in the Java 2 Platform is the ability to reset the last modified time. Your question is an example of a situation that Java programmers face constantly. With each new Java release, many major features are introduced, but many minor changes also creep in, making it difficult to stay on top of all of the APIs.
Back to your question: all you have to do is call
setLastModified(long time). The time argument should be a time measured in milliseconds since midnight GMT, January 1, 1970. The method will return true if it can set the time, false if it cannot.