Q:

How to disable button for previous date before current date?  Android

I have a textview with today's date and two button when onclick will set text view to next or prev date.  Now i want to disable the previous button if textview is showing current date.  That is if today's date is 1/3, user can go to 1/4 and after and switch between future dates.  But user can't go to 1/2 or any date before current date. 
        tvShowDate = (TextView) findViewById(R.id.tvShowDate);

    long date = System.currentTimeMillis();

    final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMMdd");
    String dateString = sdf.format(date);
    tvShowDate.setText(dateString);

    ivPrevDate = (ImageView) findViewById(R.id.ivPrevDate);
    ivNextDate = (ImageView) findViewById(R.id.ivNextDate);

    final Calendar c = Calendar.getInstance();
    final String[] formattedDate = {sdf.format(c.getTime())};

    ivPrevDate.setOnClickListener(new View. OnClickListener() {

        @Override
        public void onClick(View v) {

            c.add(Calendar. DATE, -1);
            formattedDate[0] = sdf.format(c.getTime());

            Log.v("PREVIOUS DATE : ", formattedDate[0]);
            tvShowDate.setText(formattedDate[0]);
        }
    });

    ivNextDate.setOnClickListener(new View. OnClickListener() {

        @Override
        public void onClick(View v) {

            c.add(Calendar. DATE, 1);
            formattedDate[0] = sdf.format(c.getTime());

            Log.v("NEXT DATE : ", formattedDate[0]);
            tvShowDate.setText(formattedDate[0]);

        }
    });

A:

try this function:
public boolean Check_valid_date(CharSequence d) {
    SimpleDateFormat sdf = new SimpleDateFormat("dd MMMM yyyy");
    Date date_new = null;
    try {
        date_new = sdf.parse(d.toString());
        Date current_date = new Date();
        current_date = removeTime(current_date);
        Log.d("CurentDate", current_date.toString());
        Log.d("NEW date", date_new.toString());
        if (current_date.equals(date_new)) {
            return true;
        }
        return current_date.before(date_new);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return false;
}

 public Date removeTime(Date date) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);
    cal.set(Calendar. HOUR_OF_DAY, 0);
    cal.set(Calendar. MINUTE, 0);
    cal.set(Calendar. SECOND, 0);
    cal.set(Calendar. MILLISECOND, 0);
    return cal.getTime();
}

use it as:
Calendar calendar = Calendar.getInstance();
calendar.set(year, month, day);
CharSequence date = DateFormat.format("dd MMMM yyyy", calendar.getTime());
//pass your selected date..
boolean check = Check_valid_date(date);

if(check){
    //date is after current date
    }
else{
    //date is before current date
    //disable button
    }   

