Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Java Language
Expertise: Beginner
Mar 31, 1998



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Java File date

Is there anyway with java to get a file's date?

Unfortunately, there seems to be no platform-independent way of doing this. The lastModified() method in java.io.File returns a system dependent value that can only be used to compare the dates of files. However, the Unix and Windows95 versions of the Sun JDK represent this value as the number of seconds since 00:00 January 1, 1970. Knowing this, you can convert the value to a date using the GregorianCalendar class. But if you do this, you have to keep in mind that there is no guarantee the Sun JDK will continue to represent the time of last modification in this manner. There is also no guarantee that any other JVM will use the same representation format. In other words, you cannot use this value in a portable manner.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date