I've only found 1 other instance of this issue on StackOverflow which was unanswered (last year), so I figured I'd give it another shot. (Android DatePicker/Dialog displaying incorrect month/s using min/max date, with an actual image)
When setting the minDate and maxDate of the Android DatePicker, it'll show months that are unavailable within the range of min and max date. I'll demonstrate this issue with the following images:
When I'm at the minDate:
When I'm in between the date limits:
When I'm at the maxDate:
The unavailable months (in this case April and June) act as min and max values in this situation, so going to April, the DatePicker will shoot to 15th of May, or trying to slide to June will move the DatePicker to the 22th of May.
Is it possible to keep those (unavailable) months hidden from view, so in this testcase, the only selectable part would be the date? Also keeping in mind that, with an interval between for instance the 29th of May and the 5th of June, June has to appear in the list.
I fixed that issue by resetting the current time to midnight:
Calendar date = Calendar.getInstance();
// reset hour, minutes, seconds and millis
date.set(Calendar.HOUR_OF_DAY, 0);
date.set(Calendar.MINUTE, 0);
date.set(Calendar.SECOND, 0);
date.set(Calendar.MILLISECOND, 0);
datePicker.setMaxDate(date.getTimeInMillis());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With