package other_package;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class MyTest3 
{
	
	public static void main(String[] args) {
		System.out.println(getAgeMethod());
	}
	
	 public static String getAgeMethod()
	  {
		 String ageStr;
		 Date dobDt=new Date();
		 dobDt.setDate(1);
		 dobDt.setMonth(3);
		//System.out.println("age method called");  
	    SimpleDateFormat a1 = new SimpleDateFormat("dd/MM/yyyy");
	    SimpleDateFormat a2 = new SimpleDateFormat("dd");
	    SimpleDateFormat a3 = new SimpleDateFormat("MM");
	    SimpleDateFormat a4 = new SimpleDateFormat("yyyy");
	    
	    Date d = new Date();
	    String date = a1.format(d);
	    int d1 = Integer.parseInt(a2.format(d));
	    int d2 = Integer.parseInt(a3.format(d));
	    int d3 = Integer.parseInt(a4.format(d));
	    
	    String dob = a1.format(dobDt);
	    System.out.println(dob.substring(0, 1));
	    int dob1 = Integer.parseInt(a2.format(dobDt));
	    int dob2 = Integer.parseInt(a3.format(dobDt));
	    int dob3 = Integer.parseInt(a4.format(dobDt));
	    
	    int year = d3 - dob3 - 1;
	    if ((d2 == 1) || (d2 == 3) || (d2 == 5) || (d2 == 7) || (d2 == 8) || (d2 == 10) || (d2 == 12)) {
	      d1 += 31;
	    } else if ((d2 == 4) || (d2 == 6) || (d2 == 9) || (d2 == 11)) {
	      d1 += 30;
	    } else if (((d3 % 4 == 0) && (d3 % 100 != 100)) || (d3 % 400 == 0)) {
	      d1 += 29;
	    } else {
	      d1 += 28;
	    }
	    d2 += 11;
	    int month = d2 - dob2;
	    int day = d1 - dob1;
	    if (day >= 30)
	    {
	      day -= 30;
	      month++;
	    }
	    if (month >= 12)
	    {
	      month -= 12;
	      year++;
	    }
	    ageStr = (year + " year " + month + " month " + (day - 1) + " day");
	    return ageStr;
	  }

	
}
