andyguy
andyguy

Reputation: 23

how to make android date picker to not allow past date being picked

I am using Date picker. How do we check if today and the past date cannot be selected? In php, we can compare using strtotime(now) and selected date and deduce whether it's past date or not.

Is it possible to do on Android?

Upvotes: 1

Views: 1601

Answers (1)

Vladimir Ivanov
Vladimir Ivanov

Reputation: 43108

After you have obtained the value just do:

Date fromPicker = // get the value here;
Date now = new Date();
if (fromPicker.before(now)) {
  // error !
}

Upvotes: 2

Related Questions