The task:
The programmer's day is celebrated on the 255th day of the year (January 1 is considered a zero day). It is required to write a program that determines the date (month and day of the Gregorian calendar), on which Programmer's Day falls on a given year.
The date must be in the format DD / MM / YYYY , where DD is the number, MM is the month number (01 - January, 02 - February), YYYY - the year in decimal
And enter an integer from 1 to 9999 inclusive, year of our era.
Here is the code:
Scanner in = new Scanner(System.in); int YEAR = in.nextInt(); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); Calendar gCal = new GregorianCalendar(YEAR, 0, 0); gCal.add(Calendar.DAY_OF_YEAR, 256); String dayP = sdf.format(gCal.getTime()); System.out.println(dayP); I can not understand the problem. In the compiler, everything goes as I need, in Leap years, the day 12/09/2000, in others it is 13/09/2100.
But the site does not accept this code and does not pass the 6th test, I do not understand what data is not read. Maybe problems with Calendar and SDF ? Just a little experience with them, and I took advantage of it.