Set android datepicker date limits

brass picture brass · Mar 26, 2010 · Viewed 16.1k times · Source

I am using datePicker in android to display images based on user selected dates. I need to limit said dates to certain days for instance Jan 1st 2010 to Dec 31st 2010. Simple as that i thought but no where can i find the answer on how to limit these dates.

Does anyone know how to limit the dates for Android DatePicker

Answer

cokeby190 picture cokeby190 · Jul 7, 2014

You can just set :

dateDialog.getDatePicker().setMaxDate(new Date().getTime());

and

dateDialog.getDatePicker().setMinDate(new Date().getTime());

where dateDialog is a

new DatePickerDialog()

and the param type to set for MaxDate and MinDate is a long