Setting created timestamp of files using BasicFileAttributeView

Scott Palmer swpalmer at gmail.com
Sat Mar 5 20:35:43 UTC 2016


If it can be accomplished by native code then I would file a bug against the JDK as that is clearly where such native code belongs.

Scott

> On Mar 5, 2016, at 8:15 AM, Robert Krüger <krueger at lesspain.de> wrote:
> 
> Hi,
> 
> could anyone tell me if setting the created time of a file via
> BasicFileAttributeView is not supported on OSX? I tried using the following
> code snippet:
> 
> BasicFileAttributeView attributes =
> Files.getFileAttributeView(Paths.get(file.getAbsolutePath()),
> BasicFileAttributeView.class);
> FileTime time = FileTime.fromMillis(someNewTimeInMillis);
> attributes.setTimes(time, time, time);
> 
> Finder displays last modified and last opened (i.e. last accessed, I
> assume) as the value specified by someNewTimeInMillis but created remains
> at the old value.
> 
> Is this simply not supported on OSX and I have to use a native call to do
> this?
> 
> Thanks in advance for any hint.
> 
> Robert


More information about the macosx-port-dev mailing list