文件的最后修改时间是一个 13 位数字。这是什么意思?
long lastmodify = f.lastModified();
System.out.println("File Lost Modify:"+lastmodify);
我正在运行上面的文件代码(“f”),但它显示最后修改时间是:1267082998588 我很困惑,这是时间还是时间?其实它是什么?
long lastmodify = f.lastModified();
System.out.println("File Lost Modify:"+lastmodify);
I am running the above code of file("f"), but it displays the last modified time is:1267082998588
I am confusing, is this is time or not.? Actually what it is?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
看一下 文件文档。它返回自 1970 年 1 月 1 日 00:00:00 GMT(格林尼治标准时间)以来的毫秒数。
您可以这样做
Take a look at the File documentation. It returns the miliseconds since 00:00:00 GMT, January 1, 1970.
You can do this instead
它说它以毫秒为单位给出答案,但显然它没有,它以秒乘以千为单位给出答案:
在Linux中,即使使用ext4(具有微秒)分辨率),所有文件都以 000 结尾!显然,在 Windows 中,最后你会听到噪音,但不应将其误认为是毫秒,他们说,这是“近似值”
It says it gives the answer in milliseconds, but apparently it does not, it gives the answer in seconds multiplied by a thousand:
In Linux, even with ext4 (which has microsecond resolution), all files end in 000! Apparently in Windows you will get noise at the end, but it should not be mistaken for milliseconds, it is, they say, "an approximation"
这是自 Unix 纪元以来的毫秒数。
尝试:
您可以对日期做任何您想做的事情。请参阅日期、SimpleDateFormat 和 GregorianCalendar 特别是。
It's the number of milliseconds since the Unix epoch.
Try:
You can do whatever you want with the Date. See Date, SimpleDateFormat, and GregorianCalendar in particular.
看看File类中该方法的Javadoc(很清楚):
public long lastModified()
返回此抽象路径名表示的文件最后一次修改的时间。
返回:
一个长值,表示文件上次修改的时间,自纪元(1970 年 1 月 1 日 00:00:00 GMT)以来以毫秒为单位测量,如果文件不存在或文件不存在,则为 0L发生 I/O 错误
Have a look at Javadoc of the method in the File class (it is clear enough):
public long lastModified()
Returns the time that the file denoted by this abstract pathname was last modified.
Returns:
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
这也是我得到的答案之一..
This is also one of the answer i got..
这是编辑文件的日期[以毫秒表示]。它是自 1970 年 1 月 1 日以来经过的毫秒数 [也称为 Unix Epoch]
That is the date [represented in milliseconds] that the file was edited. It is the amount of milliseconds that have passed since January 1st, 1970 [also known as the Unix Epoch]