title: age calculation method doesnt return the correct age?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1116123/how-do-i-calculate-someones-age-in-java">How do I calculate someone&#39;s age in Java?</a>  </p>
  </blockquote>
  
  
  
  <p>I want to calculate the  user age , and my method  doesnt give the correct age in case if the month of birth is equal to the current month and the day of birth  less than or equal the current day ( if the user enter his birth date through the date picker  as 9/4/1990  or 4/4/1990 the age will be 21 not 22) how i can solve this problem ? what is the update i should do to get the correct age in this  case ? please help me ....</p>
  
  <p><strong>this is my method</strong> </p>
  
  <pre><code>public static  String getAge(int year,int month,int day) {
      Calendar dob = Calendar.getInstance(); 
      Calendar today = Calendar.getInstance();
  
      dob.set(year, month, day); 
      int age = today.get(Calendar.YEAR) - dob.get(Calendar.YEAR);
  
      if (today.get(Calendar.DAY_OF_YEAR) &lt; dob.get(Calendar.DAY_OF_YEAR)){
          age--; 
      }
      Integer ageInt = new Integer(age);
      String ageS = ageInt.toString();
  
      return ageS;  
  }
  </code></pre>