如何减去两个约会日期?
这个问题在这里已经有了答案:
Period有一个构造函数,它接受两个ReadableInstant
实例:
Period diff = new Period(start, end);
( ReadableInstant
是由DateTime
以及其他类实现的接口。)
从你的例子你似乎想在几秒钟内的差异,所以这应该有所帮助:
Seconds diff = Seconds.secondsBetween(start, end);
这有帮助吗? http://joda-time.sourceforge.net/key_period.html它显示了下面的例子
DateTime start = new DateTime(2004, 12, 25, 0, 0, 0, 0);
DateTime end = new DateTime(2006, 1, 1, 0, 0, 0, 0);
// period of 1 year and 7 days
Period period = new Period(start, end);
// calc will equal end
DateTime calc = start.plus(period);
// able to calculate whole days between two dates easily
Days days = Days.daysBetween(start, end);
链接地址: http://www.djcxy.com/p/36647.html