我尝试在今天之前从我的日历中禁用日期,但日期未被禁用。这是我的代码。
DateTime dateTime = this.datetimeList.get(position);
if (dateTime.isBefore(getToday())) {
cellView.setBackgroundResource(resources
.getColor(com.caldroid.R.color.caldroid_sky_blue));
tv1.setEnabled(false);
tv1.setTextColor(convertView.getResources().getColor(R.color.caldroid_white));
}
这是比较日期的正确方法吗?
答案 0 :(得分:0)
试试这个:
if (removeTime(questionDate).equals(removeTime(today))
...
public Date removeTime(Date date) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
}