What I want is to just print out the current year and the day of the year - I am using this code: Calendar calendar = Calendar.getInstance(); String year = Integer.toString(calendar.YEAR); System.out.println("year is :" + calendar.YEAR); System.out.println("year is :" + year); String dayno = Integer.toString(calendar.DAY_OF_YEAR); which is conistently printing out a 1 for the year and a 6 for the day of year - no matter when you run the program. I am sure I am just missing something obvious but I can't figure out what it is. Many Thanks - Happy Holidays!
Hi Herbert, the 'YEAR' or 'DAY_OF_YEAR' is used for 'get' and 'set' methods only according to API. So try following: int year = calendar.get(calendar.YEAR); int dayno = calendar.get(calendar.DAY_OF_YEAR); Hope this can help you.