title: How to disable future date with Datepicker
body: <p>I am trying to disable date picker for future date but getting not idea...</p>
  
  <p>Here is the what I have tried:</p>
  
  <pre><code> bday.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
  
  
               Calendar mcurrentDate=Calendar.getInstance();
                  year=mcurrentDate.get(Calendar.YEAR);
                  month=mcurrentDate.get(Calendar.MONTH);
                  day=mcurrentDate.get(Calendar.DAY_OF_MONTH);
  
  
                  DatePickerDialog   mDatePicker =new DatePickerDialog(CreateAccountActivity.this, new OnDateSetListener()
                  {   
                      @Override
                      public void onDateSet(DatePicker datepicker, int selectedyear, int selectedmonth, int selectedday) 
                      {
                              year = selectedyear; 
                              month = selectedmonth; 
                              day = selectedday;
  
                              DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");      
                              Calendar cal = Calendar.getInstance();
  
  
                              String currenttime = new String(dateFormat.format(cal.getTime()));
                              String selectedtime = new String (new StringBuilder().append(year).append("-").append(month+1).append("-").append(day));
                              String futuretime = new String (dateFormat.format(System.currentTimeMillis()));      
  
                             if(selectedtime==currenttime)
                          { 
                              Toast.makeText(getApplicationContext(), "you were not born in the future", Toast.LENGTH_SHORT).show();
                              bday.setText("");
                          }
                          else
                          {
                       bday.setText(new StringBuilder().append(year).append("-").append(month+1).append("-").append(day));
                      }}
                  },year, month, day);
                  mDatePicker.setTitle("Please select date");                
                  mDatePicker.show();
          }
      });
  </code></pre>
  
  <p><em>Stackoverflow</em> suggested to use:</p>
  
  <pre><code>mDatePicker.getDatePicker().setMaxDate(System.currentTimeMillis());
  </code></pre>
  
  <p>but in above condition how should I use this.?
  I am trying to disable future date. But not getting any idea :(</p>