java - OffsetDateTime 中的 Z 偏移是什么?

标签 java rabbitmq java-time

<分区>

这两个 OffsetDateTime 返回不同的字符串表示和不同的偏移量。

触发时间是在不同的服务中创建的,也是通过 OffsetDateTime.now() 然后通过 RabbitMQ 发送的。

这些只是 ISO-8601 格式的不同表示吗?还是我缺少有效的偏移值?

我检查了 OffsetDateTime.toString() docu ,但不确定那是否真的是我应该寻找的地方......

谢谢大家!

OffsetDateTime offsetDateTime = event.getTriggerTime();

System.out.println(offsetDateTime); //2019-06-19T08:56:19.152564Z
System.out.println(OffsetDateTime.now()); //2019-06-19T10:56:19.293893+02:00

最佳答案

这通常被称为祖鲁 时间,参见wikipedia对于 UTC 和 ISO 8601:

If the time is in UTC, add a Z directly after the time without a space. Z is the zone designator for the zero UTC offset. "09:30 UTC" is therefore represented as "09:30Z" or "0930Z". "14:45:15 UTC" would be "14:45:15Z" or "144515Z".

The Z suffix in the ISO 8601 time representation is sometimes referred to as "Zulu time" because the same letter is used to designate the Zulu time zone. However the ACP 121 standard that defines the list of military time zones makes no mention of UTC and derives the "Zulu time" from the Greenwich Mean Time which was formerly used as the international civil time standard. GMT is no longer precisely defined by the scientific community and can refer to either UTC or UT1 depending on context.

TL;DR:Z 表示具有 zero 偏移量的 UTC 时间戳。

关于java - OffsetDateTime 中的 Z 偏移是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56663985/

相关文章:

java - Webdriver/Java/Xpath : How can I click the second "Login" link

java - 对 Bitbucket API 的 HTTP PUT 请求

通过互联网的 Java RMI 连接

message-queue - 使用 Celery 动态创建队列

java - 如何使用 LocalDate 值查询 JPA LocalDateTime 字段?

java - 解码在打开的套接字上挂起

django - Celery Queue 似乎没有注册我的任务

docker - might_not_write_file cluster_nodes.config etxtbsy

Java时间: How to interpret time of ISO_DATE_TIME format

Java 8 LocalDateTime - 如何在字符串转换中保持 .000 毫秒