Skip to main content

JDK7: Why no lastChangeTime() method in BasicFileAttributes?

3 replies [Last post]
wblaszcz
Offline
Joined: 2011-05-20
Points: 0

Can the following Unix commands be mimiced in Java:
'ls -ltc' (Sort by ctime)
'find . -ctime n' (List files based on ctime)
I've looked at getCreationTime(), lastAccessTime(), and lastModifiedTime() and they don't acheive the desired result.
Thanks,
Wayne

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
wblaszcz
Offline
Joined: 2011-05-20
Points: 0

After some more testing, I found that getCreationTime() and lastModifiedTime() are producing the same results.

alanb
Offline
Joined: 2005-08-08
Points: 0

From creationTime's description "If the file system implementation does not support a time stamp to indicate the time when the file was created then this method returns an implementation specific default value, typically the last-modified-time or a FileTime representing the epoch (1970-01-01T00:00:00Z)". So the behavior you observe is expected. The time of last status change is available if you really need it, try Files.getAttribute(path, "unix:ctime").

wblaszcz
Offline
Joined: 2011-05-20
Points: 0

Thank you.
That is exactly what I was looking for.
Wayne.