Setting android datepicker min date to specific date -
I want the user to be able to choose the start date and end date. The end date must be equal to the minimum start date For example, the user chooses August 1, 2014 as the start date. When they click on the return date field, these values are passed in the form of intent extra to date-wiker_activity. In Date_picker_activity I check for these additions and currently it only sets the selected date as the date shown:
if (getIntent (.) GetExtras ()! = Null) {Int year = getIntent () .getExtras () getInt ("SELECTED_YEAR") .; Int month = getIntent () GetExtras () GetInt ("SELECTED_MONTH"); Int day = getIntent () GetExtras () GetInt ("SELECTED_DAY"); Date_picker.updateDate (year, month, day); }
But the user is still able to take dates before the selected start date.
I tried to do something like this, if the statement:
time from time = new time (); Time.set (day, month, year); Date_picker.setMinDate (time.toMillis (true) -1000);
But that does not work.
How can I set a minimum date with passed values?
After discussing the chat, we understood that this code:
date_picker.setMinDate (System.currentTimeMillis () - 1000);
Anyway, if it was being called inside the statement, the current date is setting the minimum date.
Once I moved that code for another statement, then all are working fine.
Comments
Post a Comment