File timestamp precision on Linux?

Zhong Yu zhong.j.yu at
Sun Jun 8 23:57:10 UTC 2014

Apparently, Java8 reports Linux file timestamps only in SECOND
precision? Am I doing something wrong?

Java version:

java version "1.8.0_20-ea"
Java(TM) SE Runtime Environment (build 1.8.0_20-ea-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b17, mixed mode)

Linux version:
Linux 3.10.40-50.136.amzn1.x86_64 x86_64
(an amazon aws micro instance)

Test Code:
        Path filePath = Paths.get("test.html");
        BasicFileAttributes attrs = Files.readAttributes(filePath,
        FileTime time = attrs.lastModifiedTime();
        Instant instant = time.toInstant();

which prints

but the OS apparently supports nano precision:

> stat test.html
Access: 2014-06-08 23:45:02.718953224 +0000
Modify: 2014-06-08 23:45:03.358934113 +0000

Zhong Yu

More information about the nio-dev mailing list