问题描述
|
我有两个DateTime,一个是时间“自”和“现在”
我需要的是在此之间安排时间。
我的问题是要获取的格式:
例:
因为='2010年4月17日'
现在=“ 2011年4月15日”
我想拥有“ 0年11个月29天”
如果是“ 2010年4月13日”,则结果应为:
'1年0个月2天'
但是这种逻辑让我感到困惑。
解决方法
我不完全确定我会遵循您的问题。听起来像您想要的:
DateTime since = ...;
DateTime now = ...;
Period period = new Period(since,now,PeriodType.yearMonthDay());
int years = period.getYears();
int months = period.getMonths();
int days = period.getDays();
如果不是这种情况,您能提供更多详细信息吗?