Groovy中两个日期之间的持续时间 [英] Duration between two dates in Groovy
本文介绍了Groovy中两个日期之间的持续时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谢谢
解决方案
TimeCategory 有一些获得持续时间的方法。你可以像使用它一样使用它(/ b>
use(groovy.time.TimeCategory){
def duration = date1 - date2
打印天数:$ {duration.days},小时数:$ {duration.hours}等。
}
Is there a way in Groovy to get the duration between two Date objects? The duration format I'm looking for would be something like: 2 days, 10 hours, 30 minutes...
Thanks
解决方案
TimeCategory has some methods for getting a duration. You could use it like
use(groovy.time.TimeCategory) {
def duration = date1 - date2
print "Days: ${duration.days}, Hours: ${duration.hours}, etc."
}
这篇关于Groovy中两个日期之间的持续时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文