java显示Windows UTC时间 [英] java display Windows UTC time

查看:112
本文介绍了java显示Windows UTC时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Windows将FileTime内部存储为自1.1.1601 UTC以来的100纳秒数作为64位字段,是否可以让java打印出当前数字?只是寻找一个例子,因为我找不到办法。我想打印这个号码吗?

Windows stores FileTime internally as the number of 100-nanoseconds since 1.1.1601 UTC as a 64bit field, is it possible to get java to print out the current number? Just looking for an example as I can't find a way to do it. I would like to print the number out?

任何帮助都会很棒!

谢谢。

推荐答案

Java不提供对原始文件时间的直接访问,因此如果您要求 lastModified 时间

Java doesn't provide direct access to a raw file time, so if you ask for the lastModified time

someFile.lastModified();

您将获得上次修改文件的时间,以纪元(00:00)为单位以毫秒为单位进行测量:GMT,1970年1月1日),如果文件不存在或发生I / O错误,则为0L

You will get 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

并非每个平台都跟踪相同时间与文件有关,以及它们如何在内部跟踪它是不同的。 Java尝试使用不同标准构建一个连贯的平台的一部分使用多态来将平台特定时间转换为封面下的java标准。

Not every platform tracks the "same" times in relation to a file, and how they track it internally is different. Part of Java's attempt to make a coherent platform out of the differing standards uses polymorphism to translate the platform specific times to the "java standard" under the covers.

现在转换millis返回java时间:

Now to convert the millis returned to a java time:

java.util.Date date = new java.util.Date(millis);

从那里你可以使用标准的i / o例程来显示和格式化日期(DateFormat等) 。)

From there you can use the standard i/o routines to display and format the date (DateFormat, etc.)

PS。最初由COBOL选择1/1/1601作为时代,并由微软(可能还有其他人)模仿。选择它的原因是因为它是操作系统发布时400年格里高利历周期的开始。每隔400年,闰年的模式就会重演。

PS. 1/1/1601 was chosen as the epoch by COBOL initially and mimicked by Microsoft (and possibly others). The reason it was chosen is because it's the start of the 400 year Gregorian Calendar cycle at the time the operating system was released. Every 400 years, the pattern of leap years repeats itself.

这篇关于java显示Windows UTC时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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