gpt4 book ai didi

java - 如何减去两个 joda 日期时间?

转载 作者:IT老高 更新时间:2023-10-28 20:47:40 26 4
gpt4 key购买 nike

我知道这不是“它应该工作的方式”,但仍然:如果你有两个 DateTime 对象,那么减去它们的好方法是什么?将它们转换为 Date 对象?

DateTime start = new DateTime();
System.out.println(start + " - doing some stuff");

// do stuff

DateTime end = new DateTime();
Period diff = // end - start ???
System.out.println(end + " - doing some stuff took diff seconds");

最佳答案

期间有a constructor that takes two ReadableInstant instances :

Period diff = new Period(start, end);

(ReadableInstantDateTime实现的接口(interface),其他类也一样。)

关于java - 如何减去两个 joda 日期时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15814911/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com