Checking that an entered date is before the current date I want to write a function which returns true if a selected date is smaller than the current date, else return false.

This function is working as expected but I want to know the best possible way to do this. 

private boolean isValidDate() {

    if(year&lt;yearCurr)
    {
        //selected year is small date is small
        return true;
    }else
        if(year&gt;yearCurr)
        {
            //selected year is greater date is greater
            return false;
        }else
        {
            //selected year is same as current year check month

            if(month&lt;monthCurr)
            {
                //selected month is small date is small   
                return true;
            }else
                if(month&gt;monthCurr)
                {
                    //if selected month is greater date is greater
                    return false;
                }
                else
                {
                    // selected day of month is less than or equal to current date; date is valid 
                    if(day&lt;=dayCurr)
                        return true;
                    else
                        return false;
                }
        }
}
Just wanted to chime in:


Nobody mentioned this, but isValidDate() to determine whether 1 date is earlier than another date is frankly terrible. Call it isEarlierDate()
Where are the variables? Are those variables all defined outside of this function. That does not look good.
If there is one thing you learn today it is that this

if(day&lt;=dayCurr)
    return true;
else
    return false;


should always be written as

return day&lt;=dayCurr

As per @Heslacher, write out your variable names


This is my over-commented counter-proposal:

function isEarlierDate(){

  return year &lt; currentYear || //Last year is in the past
         year == currentYear &amp;&amp; month &lt; currentMonth || //This year, earlier month is in the past
         year == currentYear &amp;&amp; month == currentMonth &amp;&amp; day &lt; currentDay || //..
         false; //This is clearly not an earlier date
}