This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Hi all, I have a textfield, in which the user enters his day of birth (in dd/mm/yy format). I would like to calculate the age of user when he enters this. 1. getCurrentDate 2. format it in order to be same with the textfield 3. substract
Is it right? or what is the best way to do this? Thanks for any help
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
create 2 calendar objects dob (set to textfield date) now (set to current time) int age = now.get(Calendar.YEAR) - dob.get(Calendar.YEAR) add age to dob if(dob.after(now)) age --; //hasn't had birthday yet
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
posted
0
How does that work out for somebody born last week?
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
> How does that work out for somebody born last week?
it would return 0
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.