问题描述
我刚刚认识到,Mac Os X不会返回任何毫秒信息给 java.io.File#lastModified()
方法。
长整数是四舍五入的,所以最具体的信息类型是在传递给 DateTime
Object之后的第二个值。
有没有办法通过其他方式获取这些信息,也许通过 java.nio.file.Files#readAttributes(Path,Class, LinkOption [])
方法,还是希望能区分毫秒?
文件系统的限制,而不是Java API的限制。根据,HFS +仅将时间戳存储为一秒的粒度。
I just recognized that Mac Os X does not return any millisecond information to java.io.File#lastModified()
method.
The long values are rounded, so the most specific kind of information is the second after transfer to a DateTime
Object.
Is there a way to get those information some other way, maybe through the java.nio.file.Files#readAttributes(Path,Class,LinkOption[])
method, or want it be possible to distinguish between milliseconds?
This is a limitation of the file system, not of the Java API. According to the format specification HFS+ only stores timestamps to a granularity of one second.
这篇关于如何返回毫秒的Mac OS X上的文件访问信息(Java)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!