AbstractBasicFileAttributeView.java (version 1.5 : 49.0, super bit)
Alan Bateman
Alan.Bateman at Sun.COM
Fri Feb 6 05:54:58 PST 2009
Helmut Schwigon wrote:
> Hallo,
>
> while testing the package java.nio.file.attribute of the snapshot-release java7(build 98) I detected that is impossible to set any time-attribute to long-values < 0. There is a private method sun.nio.fs.AbstractBasicFileAttributeView.toTimeValue that throws an IllegalArgumentException in this case.
> The NTFS file system (f.i.) doesn't make such restriction for the sign of the time-attributes. Therefore negative long-values shouldn't be illegal arguments.
>
> Helmut
>
This is expected behavior as the setTimes method is specified to throw
IAE if any of the time values are negative. The implication is that you
can't set any of the timestamps to a value that pre-dates the specified
epoch (Jan 1, 1970). Is this really a problem or how did you run into
this? If the concern is copying files then the copyTo method (with the
COPY_ATTRIBUTES option) will attempt to do the right thing. On NTFS this
means if the file is from Jan 1, 1601 then the timestamps should be
preserved if you copy to another NTFS volume. On the other hand, if you
copy that file to a FAT32 volume then the timestamps can't be copied
because that volume stores the time since 1980. If it is important to be
able to set the timestamps to negative values then we can re-examine it
but so far it has not been a problem.
-Alan.
More information about the nio-dev
mailing list