[英]Is there a Java library for calculating elapsed time?
I am wondering if there is a library one can use that calculates elapsed time? 我想知道是否可以使用一个库来计算经过的时间? Something like... if you pass it a
long
of milliseconds, you get a result like "2d 5h 12m 55s" (possibly even more formats similarly to SimpleDateFormatter
). 像...如果将其传递了
long
,您将得到类似“ 2d 5h 12m 55s”的结果(可能类似于SimpleDateFormatter
格式更多)。
I've heard of jodatime, but I've never used it. 我听说过jodatime,但从未使用过。 Can it be used for such calculations, or are there other more appropriate libraries?
可以将其用于此类计算吗,还是还有其他更合适的库?
It's not like I can't knock up a few methods myself, but I find myself doing this every now and then and that's why I'm wondering if something like this already exists. 并不是说我自己不能敲几个方法,而是我时不时地这样做,这就是为什么我想知道是否已经存在这种方法。
Use Joda time 's Period & PeriodFormatter . 使用Joda时间的Period & PeriodFormatter 。 Example .
例子
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.