We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
If you are using the Calendar class, there are a few things you must check so it works. First, import the Calendar class from the java.util package.
Then, when parsing the month parameter to an integer, remember to subtract 1 since months in Calendar go from 0 to 12.
When using the get method for Calendar.DAY_OF_WEEK, it returns a number from 1 to 7, from Sunday to Saturday, so make sure you subtract 1 if you use a string array.
Cookie support is required to access HackerRank
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 →
If you are using the Calendar class, there are a few things you must check so it works. First, import the Calendar class from the java.util package. Then, when parsing the month parameter to an integer, remember to subtract 1 since months in Calendar go from 0 to 12. When using the get method for Calendar.DAY_OF_WEEK, it returns a number from 1 to 7, from Sunday to Saturday, so make sure you subtract 1 if you use a string array.