Update to nanosecond resolution on FileTimes?

Alan Bateman Alan.Bateman at oracle.com
Fri Jun 2 09:57:42 UTC 2017

On 01/06/2017 20:43, Alexander T wrote:
> Hello Everyone!
> My name is Alexander Torstling and I'm a software engineer from 
> Stockholm. This is my first mail so I hope that this is the right 
> forum for this subject. Please let me know if this is not the case.
> So, to the matter at hand: While trying to get maximum resolution out 
> of file modification times on JDK8, I stumbled upon a comment in
> sun/nio/fs/UnixFileAttributes#toFileTime(long,long)
>  ( 
> http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/sun/nio/fs/UnixFileAttributes.java#UnixFileAttributes.toFileTime%28long%2Clong%29 
> ):
> // truncate to microseconds to avoid overflow with timestamps
> // way out into the future. We can re-visit this if FileTime
> // is updated to define a from(secs,nsecs) method.
> It seems like it's possible to re-visit this decision now, since 
> FileTime provides a "from(Instant)" method since
> 1.8, which would make it possible to up the resolution to nanoseconds.
The from(Instant) and toInstant() were added for interoperability, they 
aren't actually need for FileTime to support creating FileTime objects 
with nano second granularity. I can't think of any reason not to look at 
this again, can you create a bug to track it?


More information about the nio-discuss mailing list