如何解决ZonedDateTime解析为ZonedDateTime的另一种格式
当前位于的ZonedDateTime
`2020-06-07T14:10:00+01:00`
我正在寻找的ZonedDateTime
的格式
2020-06-07T13:10:24Z
解决方法
您可以这样做:
useEffect(() => {
const listener = () => setDeviceWidth(window.innerWidth); // keep a reference to the listener
window.addEventListener("resize",listener); // attach it to the resize event
return () => window.removeEventListener("resize",listener); // detach it on unmounting
},[]); // only run on mounting and unmounting
或者如果您必须拥有ZonedDateTime.parse("2020-06-07T14:10:00+01:00").toInstant()
:
ZonedDateTime
,
尝试以下操作:
String time = "2020-06-07T14:10:00+01:00";
所需的输出格式= 2020-06-07T13:10:24Z
ZonedDateTime zdt = ZonedDateTime.parse(time,DateTimeFormatter.ISO_ZONED_DATE_TIME);
System.out.println(zdt.format(DateTimeFormatter.ISO_INSTANT));
打印
2020-06-07T13:10:00Z
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。