P
Peter Grison
Date is driving me crazy. I simply need to calculate the age of a person:
this is what doesn't work:
public int getAge(Person person)
{
long d = new java.util.Date().getTime();
long m =person.dateOfBirth().getTime();
long l=d-m;
SimpleDateFormat formatter = new SimpleDateFormat("yy");
return (new Integer(formatter.format(age))).intValue();
}
I'm getting 91 for a person who's born in 1983
Since getYear() is depreciated I don't like to use that
I found that Calender could do the job, but how do I cast Date into
Calender in an easy way?
hints appreciated.....
Pete
this is what doesn't work:
public int getAge(Person person)
{
long d = new java.util.Date().getTime();
long m =person.dateOfBirth().getTime();
long l=d-m;
SimpleDateFormat formatter = new SimpleDateFormat("yy");
return (new Integer(formatter.format(age))).intValue();
}
I'm getting 91 for a person who's born in 1983
Since getYear() is depreciated I don't like to use that
I found that Calender could do the job, but how do I cast Date into
Calender in an easy way?
hints appreciated.....
Pete