I created a DatePickerDialog in my Activity, and I am trying to set the minDate to after 2 days.
For example, today is 25/5/2015, and I want the minDate to be: 27/5/2015
This is the code:
final DatePickerDialog dpd = new DatePickerDialog(TestActivity.this,listener,calendar.get(Calendar.YEAR)
,calendar.get(Calendar.MONTH)
,calendar.get(Calendar.DAY_OF_MONTH));
DatePicker dp = dpd.getDatePicker();
dp.setMinDate(//I want to set it to after 2 days);
I tried this but I got an error:
dp.setMinDate(System.currentTimeMillis() + 2000);
So how can it be done ?
Thanks.
Try this:
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_YEAR, 2);
dp.setMinDate(cal.getTimeInMillis()); // where DatePicker dp
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