aspose file tools*
The moose likes Java in General and the fly likes Calendar problem !! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Calendar problem !!" Watch "Calendar problem !!" New topic
Author

Calendar problem !!

Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

HI ranchers,

I am trying to set date as ' 30 April 2008' i.e 4/30/08 , but i am getting a date which is a month ahead ??

my code :


when i run this , i am expecting to get ' April 30, 2008' , but output is : 'May 30, 2008 '

what`s wrong here ? Any solution ,

Thanks,

Reagrdz,


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Months are indexed from 0, so April is actually 3. Try using the Calendar constants to avoid this sort of error, e.g.:


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

ohhh , thanks Paul, I ll burn that in my mind !!!
 
Don't get me started about those stupid light bulbs.
 
subject: Calendar problem !!