Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Gregorian calendar  RSS feed

 
Frank Black
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all. Really new to Java. Can anyone please tell me how I can use the GregorianCalendar Class to calculate how old I am in days (taking account of leap years etc)?
Thanks for any help
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Frank,
Below code was written, compiled and tested on a Windows XP machine using SUN's J2SE SDK 1.4.2_04

And gave the following output:

Good Luck,
Avi.
 
Frank Black
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Avi, Thank you very much. Exactly what I needed.
 
Gollum .
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Frank. do you know how to take the result you get and use it in another formula in another class?
Gollum.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Avi, since this was obviously a homework assignment giving some advice would have been better than giving the answer.
Of course, your answer is wrong starting tomorrow so maybe Frank can at least figure out how to make it right every day.
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thomas,

Of course, your answer is wrong starting tomorrow

Naturally it is, and done so on purpose.

since this was obviously a homework assignment

I think it would be beneficial to you if you would learn to start questioning your assumptions -- I know I have, thanks to
you
(See the last post on that page.)
Good Luck,
Avi.
[ April 01, 2004: Message edited by: Avi Abrami ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!