How can I limit the BB DateTimePicker?

735 views Asked by At

I use a DateTimePicker in my app and I want it to allow to select only past dates, I use it to allow the user to select his date of birth and I would like it to start and end at a given year.

2

There are 2 answers

2
Eric Giguere On BEST ANSWER

Well, a quick look at the DateTimePicker documentation shows that you use the setDateTime, setMaximumDate and setMinimumDate methods to set the timespans and initial date.

0
8vius On

I managed to solve this the following way:

Calendar minDate = Calendar.getInstance();
minDate.set(Calendar.DAY_OF_MONTH, 1);
minDate.set(Calendar.MONTH, Calendar.JANUARY);
minDate.set(Calendar.YEAR, 1920);

_datePicker.setMinimumDate(minDate);