This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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!
Hello. My name is Inigo Montoya. You killed my father. Prepare to die.
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.
Joined: Aug 17, 2006
Thanks for the help Pete, that 'cout << object.dataField' convention from C++ is still in my mind, I guess.