title: Android - Update minDate and maxDate of a DatePickers many times for Start date and End date
body: <p>I have two Datepickers dialog for ToDate[start] and FromDate[end].</p>
  
  <p>I am setting both datePicker max date is current date by using setMaxDate() function.</p>
  
  <p>My issue is that when </p>
  
  <p>1) I m change the date of ToDatePicker I wont set setMaxDate() of FromDatePicker. </p>
  
  <p>2) I m change the date of FromDatePicker I wont set setMinDate() of ToDatePicker.</p>
  
  <p>In My code this work 1st time but next time when I m changing both or single datepicker it not set setMaxDate(), setMinDate() function </p>
  
  <p>here is my code</p>
  
  <pre><code>dateFormatter = new SimpleDateFormat("dd-MM-yyyy", Locale.US);
      Calendar newCalendar = Calendar.getInstance();
  
      //Setting first None value to updatedDate To and from
      Util.SaveToSharedPref(MgntNCActivity.this,
              Constant.ShaPreMgntNcFilter,
              Constant.ShaPreMgntNcFilterUpdatedToDate, Constant.NoValue);
      Util.SaveToSharedPref(MgntNCActivity.this,
              Constant.ShaPreMgntNcFilter,
              Constant.ShaPreMgntNcFilterUpdatedFromDate, Constant.NoValue);
  
      datePickerDiaFrom=new DatePickerDialog(MgntNCActivity.this, new DatePickerDialog.OnDateSetListener() {
  
          @Override
          public void onDateSet(DatePicker view, int year, int monthOfYear,
                  int dayOfMonth) {
              Calendar upDateFrom = Calendar.getInstance();
              upDateFrom.set(year, monthOfYear, dayOfMonth);
              txtFromUpdatedDate.setText(dateFormatter.format(upDateFrom.getTime()));
              // System.out.println("Date 1 )GTM : "+upDateTo.getTime().toGMTString());
  
           //setting minimum limit to date Picker 'To'
             if (dateFormatter.format(upDateFrom.getTime()).equals(dateFormatter.format(NetworkUtil.getTodayDate()))) {
                  upDateFrom.set(Calendar.HOUR_OF_DAY, upDateFrom.getMinimum(Calendar.HOUR_OF_DAY));
                  upDateFrom.set(Calendar.MINUTE, upDateFrom.getMinimum(Calendar.MINUTE));
                  upDateFrom.set(Calendar.SECOND, upDateFrom.getMinimum(Calendar.SECOND));
                  upDateFrom.set(Calendar.MILLISECOND, upDateFrom.getMinimum(Calendar.MILLISECOND));
  
                  datePickerDiaTo.getDatePicker().setMinDate(upDateFrom.getTimeInMillis());
  
                  System.out.println("setting To DatePicker current date as minDate : "
                                              +dateFormatter.format(NetworkUtil.getTodayDate()));
              }else{
                  datePickerDiaTo.getDatePicker().setMinDate(upDateFrom.getTimeInMillis());
                  System.out.println("setting To DatePicker minDate : "
                              +dateFormatter.format(upDateFrom.getTime()));
  
              }
  
             //datePickerDiaTo.getDatePicker().setMinDate(upDateFrom.getTimeInMillis());
  
              Util.SaveToSharedPref(MgntNCActivity.this,
                      Constant.ShaPreMgntNcFilter,
                      Constant.ShaPreMgntNcFilterUpdatedFromDate, dateFormatter.format(upDateFrom.getTime()));
          }
      }, newCalendar.get(Calendar.YEAR), newCalendar.get(Calendar.MONTH), newCalendar.get(Calendar.DAY_OF_MONTH));
  
      datePickerDiaTo=new DatePickerDialog(MgntNCActivity.this, new DatePickerDialog.OnDateSetListener() {
  
          @Override
          public void onDateSet(DatePicker view, int year, int monthOfYear,
                  int dayOfMonth) {
              Calendar upDateTo = Calendar.getInstance();
              upDateTo.set(year, monthOfYear, dayOfMonth);
              txtToUpdatedDate.setText(dateFormatter.format(upDateTo.getTime()));
              // System.out.println("Date 1 )GTM : "+upDateTo.getTime().toGMTString());
  
           //setting maximum limit to date Picker 'From'
             if (dateFormatter.format(upDateTo.getTime()).equals(dateFormatter.format(NetworkUtil.getTodayDate()))) {
                upDateTo.set(Calendar.HOUR_OF_DAY, upDateTo.getMaximum(Calendar.HOUR_OF_DAY));
                upDateTo.set(Calendar.MINUTE, upDateTo.getMaximum(Calendar.MINUTE));
                upDateTo.set(Calendar.SECOND, upDateTo.getMaximum(Calendar.SECOND));
                upDateTo.set(Calendar.MILLISECOND, upDateTo.getMaximum(Calendar.MILLISECOND));
  
                datePickerDiaFrom.getDatePicker().setMaxDate(upDateTo.getTimeInMillis());
  
               System.out.println("setting From DatePicker current date as maxDate : "
                          +dateFormatter.format(NetworkUtil.getTodayDate()));
              }else{
                  datePickerDiaFrom.getDatePicker().setMaxDate(upDateTo.getTimeInMillis());
                  System.out.println("setting From DatePicker maxDate : "
                          +dateFormatter.format(upDateTo.getTime()));
              }
  
             //datePickerDiaFrom.getDatePicker().setMaxDate(upDateTo.getTimeInMillis());
  
              Util.SaveToSharedPref(MgntNCActivity.this,
                      Constant.ShaPreMgntNcFilter,
                      Constant.ShaPreMgntNcFilterUpdatedToDate, dateFormatter.format(upDateTo.getTime()));
  
          }
      }, newCalendar.get(Calendar.YEAR), newCalendar.get(Calendar.MONTH), newCalendar.get(Calendar.DAY_OF_MONTH));
  
      //setting max limit to date Picker
      datePickerDiaTo.getDatePicker().setMaxDate(NetworkUtil.getTodayDate().getTime());
      datePickerDiaFrom.getDatePicker().setMaxDate(NetworkUtil.getTodayDate().getTime());
  </code></pre>
  
  <p>Any one please suggest me solution of this ...
  Thanks...    </p>