【问题标题】:How do I print a ZonedDateTime with timezone but without hyphen?如何打印带时区但不带连字符的 ZonedDateTime?
【发布时间】:2022-06-16 00:53:50
【问题描述】:

我需要在 URL 中使用日期,因此日期不能包含任何符号,例如连字符 -、破折号 / 或冒号 :

我认为20220615T160543Z 是唯一合适的格式,但问题是它是 UTC,但我需要它在其他时区。

有没有类似20220615T160543+2:00 的东西,其中+2:00 部分表示与UTC 的时区偏移?

如果是,我可以从ZonedDateTime 对象中打印出来吗?

我目前拥有的对象是

ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(date.getStartsOn().toInstant(), timezone);

提前致谢!

【问题讨论】:

  • 您确实意识到百分比编码是一回事吧?

标签: java date datetime


猜你喜欢
  • 1970-01-01
  • 2022-07-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-04-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多