问题描述
当前位于的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