Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes Question on Gregorian Calendar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

Question on Gregorian Calendar

Saathvik Reddy
Ranch Hand

Joined: Jun 03, 2005
Posts: 228
Hi,

I have this code:

I am not getting the correct year with gc.YEAR. How to i get the year?

Thanks,
Srikanth.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18507
    
  40

I am not getting the correct year with gc.YEAR. How to i get the year?


Quite frankly,. I am surprised that MONTH worked !!

MONTH and YEAR are not the month and year. These are constant values which are used by the setter and getters to determine what you want. Basically, when you pass MONTH to the getter, it will return the month, and when you pass YEAR to the getter, it will return the year.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

Please do not cross-post the same question in multiple forums. It wastes people's time when multiple redundant conversations take place. Please read this for more information.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Question on Gregorian Calendar
 
Similar Threads
JAVA FILE INPUT-OUTPUT ... SOMEONE PLEASE HELP!!!!!
HTML and Servlets
how do i get todays dat without the time
TimeStamp.toString() does not work as expected
need to offset a date by intervals of 1 year