title: How to create method for age calculation method in android
body: <p>I want to write a method to calculate the age from the birth date, is the logic correct and how to write it in android Java:</p>
  
  <pre><code>public int calculateAge(String birthday){ 
   // consider that birthday format is ddmmyyyy;
  
   String today = SystemDate(ddmmyyyy);
   int bDay = birthday(1,2).toInteger;
   int bMonth = birthday(3,4).toInteger;
   int bYear = birhtday(5,8).toInteger;
  
   int tDay = today(1,2).toInteger;
   int tMonth = today(3,4).toInteger;
   int tYear = today(5,8).toInteger;
  
   if (tMonth == bMonth){
       if (tday&gt;= bDay){ 
          age = tYear - bYear;
        else 
          age = tYear - bYear - 1;}
   else
     if (tMonth &gt; bMonth) {
         age = tYear - bYear;
     else 
         age = tYear - bYear - 1;}
   }
   return age;
  }
  </code></pre>