Everywhere I looked, they write about before() , after() , compareTo() . But the problem is that I have two buttons and one calendar only.
Here are the clicks of the two buttons:
public void initButtonListeners(final Date today, final Calendar nextYear) { findViewById(id.linearCalendar).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showCalendarInDialog("Выберите дату выезда", R.layout.calendar_dialog_customized); if (departData == null) { dialogView.init(today, nextYear.getTime()) .withSelectedDate(new Date()); } else { dialogView.init(today, nextYear.getTime()) .withSelectedDate(new Date(departData)); } isFrom = true; } }); findViewById(id.linearArrive).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showCalendarInDialog("Выберите дату приезда", R.layout.calendar_dialog_customized); if (arriveData == null){ dialogView.init(today, nextYear.getTime()) .withSelectedDate(new Date()); } else { dialogView.init(today, nextYear.getTime()) .withSelectedDate(new Date(arriveData)); } isFrom = false; } }); } Click on date:
dialogView.setOnDateSelectedListener(new CalendarPickerView.OnDateSelectedListener() { DateFormat dateFormat = new SimpleDateFormat("dd MMM yyyy"); DateFormat dayOfWeek = new SimpleDateFormat("EEEE"); @Override public void onDateSelected(Date date) { if(isFrom){ departData = dateFormat.format(date); departdOw = dayOfWeek.format(date); tvDepart.setText(departData); tvSubDepart.setText(departdOw); }else{ arriveData = dateFormat.format(date); arrivedOw = dayOfWeek.format(date); tvArrive.setText(arriveData); tvSubArrive.setText(arrivedOw); } theDialog.dismiss(); } }); I need to withdraw Toast if I chose a arrival date which is less than the departure date. And tried to compare departDate with arriveDate ... But the error, because they are String type. but there is nothing to compare him.
Question:
How to be in this case, how to compare?