This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Java in General and the fly likes Calendar fields Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Calendar fields" Watch "Calendar fields" New topic

Calendar fields

Paid O'Cuana

Joined: Mar 05, 2003
Posts: 24
I'm having trouble with the Calendar class.
I create my Calendar like so:
Calendar rightNow = new GregorianCalendar();
When I check what year it is
System.out.println("The year is "+rightNow.YEAR);
it prints out '1' for some reason
I even tried
and the did the System.out and it still said 1.
If I print out the string version of the Calendar instance
it shows the YEAR field as 2003, but any operation I use YEAR in has YEAR set to 1.
Any idea what stupid mistake I'm making?
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
You are printing the value of the YEAR constant not getting the year from the Calendar.
I agree. Here's the link:
subject: Calendar fields
It's not a secret anymore!