Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date add() does not return correct year

Status
Not open for further replies.

gotchausa

Programmer
Jan 24, 2002
64
CA
I'm trying to do something like this:

1. Get today's date: lets say Jan 1, 2003
2. todayDate.add(Calendar.Date, -1);
3. The return output is:
yy - 2003
mth - Jan
dd - 31

I'm expecting the new date to be Dec 31, 2002. What went wrong?
 
as java is case-sensitive, you'll need to refer to Calendar.DATE correctly. otherwise, if i'm missing something else, you'll want to show your code so i can catch the rest of the context. Liam Morley
lmorley@gdc.wpi.edu
"light the deep, and bring silence to the world.
light the world, and bring depth to the silence."
 
OK, I checked my code and realize that the month starts at 0 for Jan. etc. I put it as 1 in my code, hence the results was correct. My oversight! Thx.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top