title: how to calculate the exact age of a person from date of birth in android
body: <pre><code>  First example: birthdate :10-01-1991(ddmmyyyy) 
                   CurrentDate :10-01-2017 
  </code></pre>
  
  <p>if above is the condition then I want to print 26 as  current age. 
        Second example: birthdate :25-07-1991(ddmmyyyy)<br>
                        CurrentDate :10-01-2017 
   if above is the condition then I want to print 25 as current age.</p>
  
  <p>please help me ....!!!!!!</p>
  
  <p>Below is the code that i have tried.      </p>
  
  <pre><code>private int calculateage(Integer day1, Integer month1, Integer year1)
  {
  Calendar birthCal = new GregorianCalendar(1991, 01, 10);
  
  Calendar nowCal = new GregorianCalendar();
  
  age = nowCal.get(Calendar.YEAR) - birthCal.get(Calendar.YEAR);
  boolean isMonthGreater = birthCal.get(Calendar.MONTH) &gt;= nowCal
          .get(Calendar.MONTH);
  
  boolean isMonthSameButDayGreater = birthCal.get(Calendar.MONTH) &gt;= nowCal.get(Calendar.MONTH)
          &amp;&amp; birthCal.get(Calendar.DAY_OF_MONTH) &gt;= nowCal
                  .get(Calendar.DAY_OF_MONTH);
  
  if (age &lt; 18) {
      Age = age;
  }
  else if (isMonthGreater || isMonthSameButDayGreater) {
      Age = age - 1;
  }
  return Age;
  </code></pre>
  
  <p>}</p>