This week's book giveaway is in the Java 9 forum.
We're giving away four copies of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications and have Sander Mak & Paul Bakker on-line!
See this thread for details.
Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
    Bookmark Topic Watch Topic
  • New Topic

Question on Gregorian Calendar  RSS feed

 
Saathvik Reddy
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 23289
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66255
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
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.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!