Last Modified Date : Java Glossary

go to home page L words local find full screen, hide local find menu Google search web for more information on this topic jump to foot of page translate this page with Babelfish punctuation 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z (all) ©1996-2009 Roedy Green, Canadian Mind Products
Last Modified Date
The Java spec says you cannot trust the value of File.lastModified to have any particular representation. It turns out it can be trusted after all, though it only became official with JDK 1.2. Even on Win95 it returns the number of milliseconds since 1970-01-01 00:00 UTC.

With Java 1.4 you can now set the date as well with File.setLastModified ( long timestamp )

I have written FileTimes a native class for windows that lets you get and set three of the file dates from Java.

You can examine the date with File.lastModified() and set it in Java 1.4+ with File.setLastModified()
BigDate to see how you might convert these to dates and times
but you cannot get or set the created or lastAccessed dates without without native code. I have written such native code called FileTimes to let you get/set all three dates to 1 ms precision.

Windows keeps file timestamps accurate to 100 nanoseconds with 10,000 times as much precision as Java’s 1 ms. This means if you copy a file in Java, the new file might not have the exact same timestamp as the old. When you reconstitute a zipped file, its timestamp will be reconstituted accurate only to the even 2 seconds.


CMP homejump to top You can get the freshest copy of this page from: or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror)
http://mindprod.com/jgloss/lastmodified.html J:\mindprod\jgloss\lastmodified.html
CMP logofeedback Please email your feedback for publication, errors, omissions, typos, formatting errors, ambiguities, unclear wording, broken/redirected link reports, suggestions to improve this page or comments to Roedy Green : feedback email
mindprod.com IP:[65.110.21.43]
view BlogYour face IP:[38.107.191.101]
You are visitor number 40,101.