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
      

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...