如何返回毫秒的Mac OS X上的文件访问信息(Java)? [英] How to return millisecond information for File Access on Mac Os X (in Java)?

查看:125
本文介绍了如何返回毫秒的Mac OS X上的文件访问信息(Java)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚认识到,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)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆