Calendar c = Calendar.getInstance();
c.set(2019, 12, 29);
When i did c.getTime() i got the following output…
Output:
Wed Jan 29 17:15:27 IST 2020 // Should have been 2019
/////————————————————————-//////
Calendar c = Calendar.getInstance();
c.set(2019, 11, 29);
When i did c.getTime() i got the following output…
Output:
Sun Dec 29 17:18:23 IST 2019
Now i don’t know why changing the Month from 12th to 11th gave me the correct date and time, i would be really obliged if someone can explain this simply and if possible with a small uncomplicated example.
Months in a
Calendarare zero-basedAssuming a Gregorian calendar,
11is December, and12is January of next year, precisely the way your program shows it.