You are viewing a single comment's thread. Return to all comments →
In this code there is one cofusion every begginer will face that is why month -1 is there in this line of code:
Explanation : Calendar class represents months as 0-indexed.
So January is 0, February is 1, ... November is 10 and December is 11. So if we are giving Aughust which 8th month. you must pass 7 (i.e., 8 - 1).
as
Seems like cookies are disabled on this browser, please enable them to open this website
Java Date and Time
You are viewing a single comment's thread. Return to all comments →
In this code there is one cofusion every begginer will face that is why month -1 is there in this line of code:
calendar.set(year, month-1, day);Explanation : Calendar class represents months as 0-indexed.
So January is 0, February is 1, ... November is 10 and December is 11. So if we are giving Aughust which 8th month. you must pass 7 (i.e., 8 - 1).
as