Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Age Calculation in Years

807598Nov 23 2005 — edited Dec 14 2005
I'm rather new to Java, but as a UI designer I've managed to get wrangled into a Java-based project. Anyhow, my mission today is to find the best method of calculating a person's age in years. I will be obtaining the date from a database (using dbSwing), where it is stored in YYYY-MM-DD format as a date.

I can retrieve the value as a String, Date, or a few other types, but given the particular format of the stored value, I wasn't sure which would be best in passing as a parameter to the end method.

In summary, I need to take a YYYY-MM-DD date and compare it to the current date to obtain a person's age in years. I note that there are comments concerning 1970 and wasn't sure if any dates before that year would a problem in this calculation.

I've search about and not really found anything that seems to fit, but again, I'm quite new to the non-UI related parts of Java and any pointers in the right direction would be greatly appreciated. Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 11 2006
Added on Nov 23 2005
9 comments
191 views