How to compare system date with user selected date in onSelectedDayChange()? If user selects a date in the past then give an alert, otherwise I want to move to the next activity.
My code is:
public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) {
    SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
    //String sday = (""+dayOfMonth);
    //String smonth=("-"+month);
    //String syear=("-"+year);
     s = ("" + dayOfMonth + " : " + (month + 1) + " : " + year);
    try {
        strDate = formatter.parse(s);
        Date systemdate = new Date(System.currentTimeMillis());
        if (systemdate.compareTo(strDate)>0) {
            Toast.makeText(getApplication(), "wrong date", Toast.LENGTH_LONG).show();
        }
        else {
            Intent in = new Intent(MainActivity.this, sec.class);
            s = +dayOfMonth + " : " + (month + 1) + " : " + year;
            in.putExtra("TextBox", s.toString());
            startActivity(in);
            Toast.makeText(getBaseContext(), "Selected Date is\n\n" + dayOfMonth + " : " + (month + 1) + " : " + year,
                    Toast.LENGTH_SHORT).show();
        }
    } catch (ParseException e) {
       e.printStackTrace();
    }
}
 
     
    