title: StackOverflowError while using Android Calendar's setMinDate()
body: <p><img src="https://i.stack.imgur.com/sO9Tm.png" alt="screen of my problem "></p>
  
  <p>refer to the error shown in the image above.</p>
  
  <p>This problem is shown when I set <code>calendarView.setMinDate</code>
  and I can't solve I am facing this problem when I use the calender </p>
  
  <blockquote>
    <p>Background concurrent copying GC freed 98234(2MB) AllocSpace objects,
    1(1564KB) LOS objects, 41% free, 34MB/58MB, paused 139us total
    366.099ms</p>
  </blockquote>
  
  <p><strong>here is my code</strong></p>
  
  <pre><code> public class select_time extends BaseActivity {
  
      @BindView(R.id.calendarView)
      CalendarView calendarView;
      DatesView datesView;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.select_time);
          ButterKnife.bind(this);
          in = getIntent().getBooleanExtra("in", true);
          datesView = new DatesView(findViewById(R.id.datesView));
          datesView.setOnCalenderClick(new DatesView.onClenderClick() {
              @Override
              public void OnClick(boolean in) {
                  setWanted(in);
              }
          });
          datesView.refresh(this);
          refreshCalendar();
          calendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
              @Override
              public void onSelectedDayChange(CalendarView view, int year, int month, int day) {
                  Calendar calendar = Calendar.getInstance();
                  calendar.set(year, month, day, 0, 0, 0);
                  SharedPreferences prefs = getSharedPreferences("data", 0);
                  prefs.edit().putLong((in ? "in" : "out") + "_date", calendar.getTimeInMillis()).apply();
                  if (in) {
                      if (calendar.getTimeInMillis() == out_date.getTime() || calendar.getTimeInMillis() &gt;= out_date.getTime()) {
                          calendar.add(Calendar.DATE, 1);
                          prefs.edit().putLong("out_date", calendar.getTimeInMillis()).apply();
                      }
                  } else {
                      if (calendar.getTimeInMillis() == out_date.getTime() || calendar.getTimeInMillis() &lt;= out_date.getTime()) {
                          calendar.add(Calendar.DATE, -1);
                          prefs.edit().putLong("in_date", calendar.getTimeInMillis()).apply();
                      }
                  }
                  datesView.refresh(select_time.this);
              }
          });
      }
      Date in_date,out_date;
      public void refreshCalendar(){
          SharedPreferences prefs = getSharedPreferences("data", 0);
          in_date = new Date(prefs.getLong("in_date", 0));
          out_date = new Date(prefs.getLong("out_date", 0));
          calendarView.setMinDate(System.currentTimeMillis() - 1000);
          calendarView.setDate(in ? in_date.getTime() : out_date.getTime());
          setWanted(in);
  
      }
      boolean in;
      public void setWanted(boolean in) {
          this.in = in;
          datesView.check_in.setBackgroundColor(getResources().getColor(in ? R.color.gray : R.color.white));
          datesView.check_out.setBackgroundColor(getResources().getColor(!in ? R.color.gray : R.color.white));
          refreshCalendar();
      }
      public void clickDone(View view) {
          finish();
      }
  }
  </code></pre>
  
  <p>Can anyone help me with using Calender?</p>