the-alexgator the-alexgator - 1 year ago 108
Java Question

Get Current Day (Monday, Tuesday, etc) in Java

I am working on a program that asks the user which day they would like to see a lunch menu for. They can enter any day by name (Monday, Tuesday, etc.). This works well, but I would also like them to be able to enter "Today" and then have the program get the current date and then check the menu for that value.

How would I do this?


Answer Source

You can use java.util.Calendar:

Calendar calendar = Calendar.getInstance();
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download