Calendar today = Calendar.getInstance();
Calendar old = Calendar.getInstance();
//此处的isEver everType startTime createDate为pojo的属性
if (("Y".equals(isEver) && everType == 2) || startTime == null) {
old.setTime(createdDate);
} else {
old.setTime(startTime);
}
//此处好像是去除0
today.set(Calendar.HOUR, 0);
today.set(Calendar.MINUTE, 0);
today.set(Calendar.SECOND, 0);
old.set(Calendar.HOUR, 0);
old.set(Calendar.MINUTE, 0);
old.set(Calendar.SECOND, 0);
//老的时间减去今天的时间
long intervalMilli = old.getTimeInMillis() - today.getTimeInMillis();
int xcts = (int) (intervalMilli / (24 * 60 * 60 * 1000));
// -2:前天 -1:昨天 0:今天 1:明天 2:后天, out:显示日期
if (xcts >= -2 && xcts <= 2) {
return String.valueOf(xcts);
} else {
return "out";
}