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 rightNow.set(rightNow.YEAR,2003); and the did the System.out and it still said 1. If I print out the string version of the Calendar instance System.out.println(rightNow.toString()); 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?
posted 14 years ago
Try rightNow.get(Calendar.YEAR) You are printing the value of the YEAR constant not getting the year from the Calendar.