问题描述
我今天在 vb6 中编写了一些代码,它可以获得自 1970 年 1 月 1 日以来的毫秒数,因此我可以将值发送到 java 应用程序,该应用程序将解析该值,如 new date(long.parse(毫秒)).我知道 date(long) 正在寻找的毫秒数是自 gmt 纪元以来的毫秒数.我正在运行的机器在美国的 cdt 上.当我得到从毫秒解析的日期的 tostring 值时,这是我得到的值:
i wrote some code today in vb6 which would get me the number of milliseconds since 1/1/1970, so i could then send the value off to a java application which would parse that value like new date(long.parse(milliseconds)). i understand that the milliseconds the date(long) is looking for is the number of milliseconds since epoch in gmt. the machine i am running on is on cdt here in the us. when i get the tostring value of the date parsed from the milliseconds, this is the value i get:
tue aug 11 15:40:50 cdt 2015
cdt 就在那里,因为本地机器时区是 cdt?我只是认为 date 的构造函数会假设从 gmt 纪元以来的毫秒数派生的日期将隐含在本地机器时区中,而不是偏移(在这种情况下)-5 小时,这有点奇怪.
is the cdt just there because the local machines timezone is cdt? i just think its a little weird that the constructor for date would assume that a date derived from the milliseconds since epoch in gmt would implicitly be in the local machines timezone, rather than being offset (in this case) by -5 hours.
推荐答案
cdt 就在那里,因为本地机器时区是 cdt?
is the cdt just there because the local machines timezone is cdt?
用于显示的时区基于默认时区.
the timezone for display purposes is based on the default time zone.
日期中的毫秒是相对于纪元的,它没有自己的时区.
the millis in the date is relative to epoch and it doesn't have a time zone of its own.
它是从格林威治标准时间 1970 年 1 月 1 日 00:00 开始拍摄的,或者如果您更喜欢 1969 年 12 月 31 日 17:00 cdt.
it is taken since 00:00 1/1/1970 gmt or if you prefer 17:00 12/31/1969 cdt.
将隐含在本地机器时区
使用当地时区仅用于显示目的.使用另一个时区或序列化 date 并将其发送到另一个时区的机器,它将再次使用本地时区.
the use of the local time zone is for display purposes only. use another time zone or serialize the date and send it to a machine in another timezone and it will use the local timezone again.