How to set minimum DatePicker date to current date
I want to set the minimum date the user can choose in a DatePicker to the current date. I've tried this: That gives me the following exception: How do I do this? The error says you cannot set the minimum date to exactly now. Try subtracting a second: From the source code the minimum date must be before, not equal to, the current date: So you simply need to subtract enough time from now ( System.currentTimeMillis() ) pass date.before(mMinDate) . If you don't want to use a custom dialog. Use this single line code: Check the Android DatePickerDialog set minimum and maximum date code. Here is the examples. Adding this line to your DatePicker Fragment will set the minimum date as current date & disable the previous months. This can help you. Try this This worked perfectly for me. easy and nice. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie polic...