How to set minimum DatePicker date to current date

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).

Leave a Comment