当前位置: 代码迷 >> java >> 在Kotlin中获取两种ISO格式时间之间的分钟
  详细解决方案

在Kotlin中获取两种ISO格式时间之间的分钟

热度:93   发布时间:2023-08-04 09:36:23.0

我需要获取java / kotlin中ISO格式日期之间的分钟数示例:需要知道以下两个iso时间之间的分钟数

2019-02-18T06:37:00.000Z 2019-02-18T11:46:00.000Z

您可以使用和toMinutes()方法:

ZonedDateTime dt1 = ZonedDateTime.parse("2019-02-18T06:37:00.000Z");
ZonedDateTime dt2 = ZonedDateTime.parse("2019-02-18T11:46:00.000Z");
System.out.println(Duration.between(dt1, dt2).toMinutes()); // 309