# HG changeset patch # User bpb # Date 1495813868 25200 # Fri May 26 08:51:08 2017 -0700 # Node ID e2d892b8f79efdd2e52c2b36ea2768b05681bd42 # Parent 8c879b07e43e64b2a8813f6c100e71cbfb0b2e6f 6791812: (file spec) Incompatible File.lastModified() and setLastModified() for negative time Summary: Amend verbiage describing return value to explain negative values. Reviewed-by: rriggs diff --git a/src/java.base/share/classes/java/io/File.java b/src/java.base/share/classes/java/io/File.java --- a/src/java.base/share/classes/java/io/File.java +++ b/src/java.base/share/classes/java/io/File.java @@ -928,11 +928,17 @@ * the granularity of the value depends on the underlying * file system and may be larger. For example, some * file systems use time stamps in units of seconds. + * Distinguishing an I/O exception from a zero return value may + * also be accomplished by using the + * {@link java.nio.file.Files#getLastModifiedTime(Path,LinkOption[]) + * Files.getLastModifiedTime} method. * * @return A long value representing the time the file was * last modified, measured in milliseconds since the epoch * (00:00:00 GMT, January 1, 1970), or 0L if the - * file does not exist or if an I/O error occurs + * file does not exist or if an I/O error occurs. The value may + * be negative indicating the number of milliseconds before the + * epoch * * @throws SecurityException * If a security manager exists and its {@link # HG changeset patch # User bpb # Date 1495814282 25200 # Fri May 26 08:58:02 2017 -0700 # Node ID 2bd07cfd95a4424117ab9708499e4903cd8a76ed # Parent e2d892b8f79efdd2e52c2b36ea2768b05681bd42 [mq]: 6791812.01 diff --git a/src/java.base/share/classes/java/io/File.java b/src/java.base/share/classes/java/io/File.java --- a/src/java.base/share/classes/java/io/File.java +++ b/src/java.base/share/classes/java/io/File.java @@ -916,22 +916,21 @@ * Returns the time that the file denoted by this abstract pathname was * last modified. * + * @apiNote + * While the unit of time of the return value is milliseconds, the + * granularity of the value depends on the underlying file system and may + * be larger. For example, some file systems use time stamps in units of + * seconds. + * *

Where it is required to distinguish an I/O exception from the case * where {@code 0L} is returned, or where several attributes of the * same file are required at the same time, or where the time of last * access or the creation time are required, then the {@link * java.nio.file.Files#readAttributes(Path,Class,LinkOption[]) - * Files.readAttributes} method may be used. - * - * @apiNote - * While the unit of time of the return value is milliseconds, - * the granularity of the value depends on the underlying - * file system and may be larger. For example, some - * file systems use time stamps in units of seconds. - * Distinguishing an I/O exception from a zero return value may - * also be accomplished by using the + * Files.readAttributes} method may be used. If however only the + * time of last modification is required, then the * {@link java.nio.file.Files#getLastModifiedTime(Path,LinkOption[]) - * Files.getLastModifiedTime} method. + * Files.getLastModifiedTime} method may be used instead. * * @return A long value representing the time the file was * last modified, measured in milliseconds since the epoch