title: How Set Max & Min Date In WHEEL DatePicker In Android
body: <p>In my application am trying <a href="http://www.codeofaninja.com/2013/08/android-date-picker-example.html" rel="nofollow">DatePicker</a> to set date.I want to set date picker Maximum date is as today date according to system date.i don't know how to set date picker maximum date as today date.May I know what is the correct way to achieve my objective?Maybe this question too basic, but i did't find any suitable solution.Please Help me out</p>
  
  <p>Here is my code :</p>
  
  <pre><code>    public class UserDob extends Activity {
  
      TextView tvDisplayDate;
       DatePicker datePickerBirthday;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_user_dob);
  
          ActionBar ab = getActionBar(); 
          ab.setDisplayUseLogoEnabled(false);
          ab.setDisplayShowHomeEnabled(true);
          ab.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); 
          ab.setCustomView(R.layout.actionbar);
          ab.setDisplayHomeAsUpEnabled(true);
          ColorDrawable colorDrawable = new ColorDrawable(Color.parseColor("#FFFFFF"));     
          ab.setBackgroundDrawable(colorDrawable);
  
          datePickerBirthday=(DatePicker)findViewById(R.id.dpResult);
          tvDisplayDate = (TextView)findViewById(R.id.textViewUserDate);
  
           int currentapiVersion = android.os.Build.VERSION.SDK_INT;
              if (currentapiVersion &gt;= 11) {
                  datePickerBirthday.setCalendarViewShown(false);
              }
  
              SimpleDateFormat sdfDateTime = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
              String dateStr = sdfDateTime.format(new Date(System.currentTimeMillis()));
  
              String[] dateSplit = dateStr.split("-");
              int currentYear = Integer.parseInt(dateSplit[0]);
              int currentMonth = Integer.parseInt(dateSplit[1]);
              int currentDay = Integer.parseInt(dateSplit[2]);
  
              // to show date and day of week in the TextView
              setHumanReadableDate(currentYear, currentMonth, currentDay);
  
              // initialize date picker listener
              // currentMonth - 1, because on the picker, 0 is January
              datePickerBirthday.init(currentYear, currentMonth - 1, currentDay, birthdayListener);
  
  
      }
       // the date picker listener
     OnDateChangedListener birthdayListener = new OnDateChangedListener() {
  
         @Override
         public void onDateChanged(DatePicker birthDayDatePicker,
                 int newYear, int newMonth, int newDay) {
  
             try{
  
                 // currentMonth + 1, to retrieve proper month
                 setHumanReadableDate(newYear, newMonth + 1, newDay);
  
             } catch (NullPointerException e) {
                 e.printStackTrace();
             } catch (Exception e) {
                 e.printStackTrace();
             }
         }
     };
  
     // show the user a better date format
     public void setHumanReadableDate(int newYear, int newMonth, int newDay){
         try {
  
             String clickedDate = newYear + "-" + newMonth + "-" + newDay;
             SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
             Date d = null;
              try {
                  d = sdf.parse(clickedDate);
              } catch (java.text.ParseException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
  
             SimpleDateFormat sdfDateTime = new SimpleDateFormat("MMMM dd, yyyy 'is' EEEE", Locale.US);
             String dateStr = sdfDateTime.format(d);
  
             tvDisplayDate.setText(dateStr);
  
         } catch (ParseException e) {
             e.printStackTrace();
         }
     }
  }
  </code></pre>