FULL PRODUCT VERSION : java version "1.6.0_15" Java(TM) SE Runtime Environment (build 1.6.0_15-b03) Java HotSpot(TM) 64-Bit Server VM (build 14.1-b02, mixed mode) ADDITIONAL OS VERSION INFORMATION : Linux universe 2.6.31-20-generic #58-Ubuntu SMP Fri Mar 12 04:38:19 UTC 2010 x86_64 GNU/Linux EXTRA RELEVANT SYSTEM CONFIGURATION : ext4 hard disk partition A DESCRIPTION OF THE PROBLEM : incorrect precision of lastModified() of java.io.File on Ubuntu x64 Linux According to https://ext4.wiki.kernel.org/index.php/Ext4_Howto#Inode-related_features ext4 support time precision up to nanosecond According to http://java.sun.com/javase/6/docs/api/java/io/File.html#lastModified%28%29 the lastModified() function support resolution up to microsecond. In fact, the function also return '000' at the end of number, which is inaccurate STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : list a directory by the following shell command (will show the full timestamp) ls -la --full-time / write a simple java program to display the lastModified time of any file EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - lastModified time up to microseconds should be shown ACTUAL - The end of the number is always 000, which is inaccurate REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import java.io.*; public class test { public static void main(String[] args) throws Throwable { String path="/etc/fstab"; System.out.println("File: "+path+" , last modified: "+Long.toString(new java.io.File(path).lastModified())); } } ---------- END SOURCE ----------
|