The error says you cannot set the minimum date to exactly now. Try subtracting a second:
datePicker.setMinDate(System.currentTimeMillis() - 1000);
From the source code the minimum date must be before, not equal to, the current date:
if (date.before(mMinDate)) {
throw new IllegalArgumentException("fromDate: " + mMinDate.getTime()
+ " does not precede toDate: " + date.getTime());
}
So you simply need to subtract enough time from now (System.currentTimeMillis()
) pass date.before(mMinDate)
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…