We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
即时
仍然是最佳选择,但是您可能需要一些辅助对象。例如,创建开始日期(根据需要替换
z
,请根据需要替换):然后进行给定的日期。您可以解析它,也可以使用转换方法。例如,如果您有一个
localdateTime
(使用不同的ZeardID
或ZoneOffset
根据需要):现在获取持续时间:
Instant
is still the best option, but you may need some helper objects.For instance, to create the start date (replace the
Z
with a different time zone or offset as needed):Then take the given date. You can parse it, or use conversion methods. For instance, if you have a
LocalDateTime
(use a differentZoneId
orZoneOffset
as needed):Now get a duration: