gpt4 book ai didi

java - 打印 GMT 和 PST 时间戳显示仅相差 7 小时

转载 作者:行者123 更新时间:2023-12-02 06:11:32 25 4
gpt4 key购买 nike

我的理解是 PST 与 GMT/UTC 相差 8 小时。然而,当我打印出来时,我发现只相差7个小时。你能解释一下我在这里做错了什么吗?

    SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
Date date = sdf1.parse("2014-05-01 13:31:03.7");

SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd_HHmmssS");
df.setTimeZone(TimeZone.getTimeZone("PST"));
System.out.println(df.format(date));
df.setTimeZone(TimeZone.getTimeZone("GMT"));
System.out.println(df.format(date));
df.setTimeZone(TimeZone.getTimeZone("UTC"));
System.out.println(df.format(date));

打印:

20140501_1331037
20140501_2031037
20140501_2031037

最佳答案

我假设您在夏季/夏令时(GMT+7)执行 PST。尝试仲冬。

来自http://wwp.greenwichmeantime.co.uk/time-zone/usa/pacific-time/

When does Pacific Time change to Daylight Saving Time?

In most states in the USA and in most provinces in Canada, Daylight-Saving Time (DST) is observed. During DST PT or PDT is 7 hours behind Greenwich Mean Time (GMT-7).

After the Summer months Pacific Time is shifted back by 1 hour to US Pacific Standard Time (PST) or (GMT-8).

The schedule for the states of the United States that adopt daylight saving time are:

2 a.m. on the Second Sunday in March to

2 a.m. on the First Sunday of November.

关于java - 打印 GMT 和 PST 时间戳显示仅相差 7 小时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27616890/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com