Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GregorianCalendar issues - how to display?

 
James Brooks
Gunslinger
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again!

Now I'm having trouble with displaying the GregorianCalendar dates. Code is below, but what is happening is that my GregorianCalendar objects are always displaying 2/1/5 as the date, no matter what values I instantiate them with or set them with via the mutator method. Can someone tell/show me the correct way to display such an object? Thanks!


 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A java convention is that all-CAPS are constants or enumerations. What you think may be class properties (YEAR, MONTH,) is actually a constant that holds the field number for the get routine. If you call myDate.get(Calender.YEAR); you'll get the year. Same call with MONTH will give you the month. Check out Class Calender at javadocs. GregorianCalender derives from the Calender superclass, so all this applies to it.

Good luck!
 
James Brooks
Gunslinger
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help Pete, that 'cout << object.dataField' convention from C++ is still in my mind, I guess.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic