This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with the Calendar

 
Daniel Serrano
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am using the Calendar to setup a date string to display and I obtain each part separately using the Calendar.getInstance.get() method and passing it the DAY_OF_MONTH, MONTH, YEAR variables. The problem is I am currently getting a 0 for month. What I am doing wrong ?
Thanks
Daniel Serrano
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're doing nothing wrong. For some reason, Calendar uses a 0-based index for months. I.e. 0=January, 1=February, 2=March and so on.
 
Daniel Serrano
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot, it would probably have taken me some time to figure that out as I was assuming there was a problem and Calendar was only returning the first digit of the month. Thanks.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!