how to disable the past date and time in android date-picker and time-picker so that user cannot select the date which has already passed and same with the time ?? please suggest me, It should be valid for future date only.
Asked
Active
Viewed 828 times
0
-
1setmindate method simple – Illegal Argument Jun 21 '14 at 07:16
-
@IllegalArgument I am a novice, too. Can you please tell me why people [here](http://stackoverflow.com/questions/17878751/how-to-disable-dates-before-today-date-in-datepickerdialog-android) are using such a long way to disable previous date when a method is available? :/ – An SO User Jun 21 '14 at 07:22
-
the answer is simple mindate() expects unix timestamp. But the Calendar api provides you with current day time and year. so you need to convert the from calendar date to unixtimestamp for setting mindate in the picker itself. I did that too. – Illegal Argument Jun 21 '14 at 07:24
1 Answers
0
public void setMinDate (long minDate)
Added in API level 11 Sets the minimal date supported by this
NumberPicker in milliseconds since January 1, 1970 00:00:00 in
getDefault() time zone.Parameters
minDate The minimal supported date.
Source: http://developer.android.com/reference/android/widget/DatePicker.html#setMinDate(long)

An SO User
- 24,612
- 35
- 133
- 221