开发者

How can I limit the BB DateTimePicker?

开发者 https://www.devze.com 2023-02-10 02:48 出处:网络
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 开发者_JAVA技巧end at a given

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 开发者_JAVA技巧end at a given year.


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.


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);
0

精彩评论

暂无评论...
验证码 换一张
取 消