Age

Is there any class that given the date of birth of a person calculates his age?Thanks
[99 byte] By [Desaa] at [2007-10-2 10:56:10]
# 1
> Is there any class that given the date of birth of a> person calculates his age?No.Have a look at the GregorianCalendar class: http://java.sun.com/j2se/1.4.2/docs/api/java/util/GregorianCalendar.html
prometheuzza at 2007-7-13 3:20:55 > top of Java-index,Java Essentials,New To Java...
# 2
no,but you could write a method to do that,have a look at the Calendar class and the SimpleDateFormat class.
wickedAndLazya at 2007-7-13 3:20:55 > top of Java-index,Java Essentials,New To Java...
# 3
Although millions of students have written code for that, it is not part of standard Java yet...
TimTheEnchantora at 2007-7-13 3:20:55 > top of Java-index,Java Essentials,New To Java...
# 4

> Although millions of students have written code for

> that, it is not part of standard Java yet...

and that's one of the reasons why. Wouldn't want every single student assignment to be part of the core language as that would make life hard on teachers :)

Birthdays are useless things anyway. Age isn't a discreet entity that can be caught in a simple number, certainly not a number of years. The year is far too long a period to define age in, weeks or days come first and even that may be too coarse a definition when talking about mayflies for example.

jwentinga at 2007-7-13 3:20:55 > top of Java-index,Java Essentials,New To Java...
# 5
> Birthdays are useless things anyway.What about Birthday parties then ?> The year is far too long a period ...You mean... between Birthday parties, don't you ?
TimTheEnchantora at 2007-7-13 3:20:55 > top of Java-index,Java Essentials,New To Java...
# 6

> > Birthdays are useless things anyway.

> What about Birthday parties then ?

>

those only cost money.

> > The year is far too long a period ...

> You mean... between Birthday parties, don't you ?

>

I avoid those, even my own (when I can).

jwentinga at 2007-7-13 3:20:55 > top of Java-index,Java Essentials,New To Java...
# 7

[url=http://www.javaworld.com/jw-12-2000/jw-1229-dates.html]Calculating Java dates: Take the time to learn how to create and use dates[/url]

[url=http://www.javaworld.com/javaworld/jw-03-2001/jw-0330-time.html]Working in Java time: Learn the basics of calculating elapsed time in Java[/url]

yawmarka at 2007-7-13 3:20:55 > top of Java-index,Java Essentials,New To Java...