1. First define an array of weeks. Because the array starts from 0, Sunday is put first, as shown in the figure:
2. Get the Calendar object, and then operate the date and time, as shown in the figure:
3. Set the passed in time into the Calendar object. As shown in the picture:
4. Because the DAY_OF_WEEK of the operating environment starts on Sunday, you need to subtract 1 here, as shown in the picture:
5. Return the execution result, as shown in the picture:
#6. Write a test method to call the above completed method, as shown in the picture:
7. Print out the execution results and display the day of the week, as shown in the figure:
## Recommended tutorial:The above is the detailed content of How to determine what day of the week a specified date is in java. For more information, please follow other related articles on the PHP Chinese website!