determing person's age

Hi I am writing a small program in which I have to determine a person's age on the basis os of date of birth. code is given below

Date dt =new Date("10/12/79");

int year = dt.getYear();

int month = dt.getMonth();

int date = dt.getDate();

// Create a calendar object with the date of birth

Calendar dateOfBirth =new GregorianCalendar(year,month,date);

// Create a calendar object with today's date

Calendar today = Calendar.getInstance();

// Get age based on year

int age = today.get(Calendar.YEAR) - dateOfBirth.get(Calendar.YEAR);

Problem is the getYear(),getMonth() and getDate() method of Date are deprecated. What do I do about it.Is there any work around. Thanks in advance.

[1081 byte] By [asterix79a] at [2007-10-2 20:26:00]
# 1
[url= http://java.sun.com/j2se/1.5.0/docs/api/java/util/Calendar.html#setTime(java.util.Date)]setTime(Date)[/url]
mlka at 2007-7-13 23:08:57 > top of Java-index,Java Essentials,New To Java...
# 2
Thanks a million
asterix79a at 2007-7-13 23:08:58 > top of Java-index,Java Essentials,New To Java...
# 3

import java.util.Calendar;

import java.util.GregorianCalendar;

public class AgeCalculator {

public static void main(String[] args) {

int dob_date = 7;

int dob_month = 5;

int dob_year = 2005;

// Create a calendar object with the DOB

Calendar dob = new GregorianCalendar(dob_year, dob_month, dob_date);

// Create a calendar object with today's date

Calendar today = Calendar.getInstance();

int diff_year = (today.get(Calendar.YEAR) - dob.get(Calendar.YEAR));

int diff_month = (today.get(Calendar.MONTH) + 1) - dob.get(Calendar.MONTH);

int diff_date = (today.get(Calendar.DATE) - dob.get(Calendar.DATE));

int age = 0;

if(diff_year > 0){

age = diff_year;

if(diff_month < 0) age = age - 1;

else if(diff_month == 0){

if(diff_date < 0) age = age - 1;

}

}

System.out.println("\nAge : " + age);

}

}

astelaveestaa at 2007-7-13 23:08:58 > top of Java-index,Java Essentials,New To Java...