title: How can I take a user inputted date instead of the current date in the Calendar class in Java?
body: <p>I'm working on an assignment, and my goal is to create a class that prints the day of the week given a date. When prompted for input, if the user enters nothing, the program is stopped. Otherwise, if the user enters a date, the program provides the day of the week and then continues to re-prompt the user. The date the user inputs will be in the format of m d y, or for example, 1 10 2017 for January 10th, 2017.</p>
  
  <p>What I have so far does everything I need, except it uses the current day, month, and year instead of the user inputted day, month, and year.</p>
  
  <pre><code>import java.util.Calendar;
  import java.util.Scanner;
  
  public class FindDayOfWeek {
  
  public static void main(String[] args) {
      Scanner s = new Scanner(System.in);
      System.out.println("Repeatedly enter a date (m d y) to get the day of week. Terminate input with a blank line.");
      String date = s.nextLine();
  
      while (true) {
  
          if (date.isEmpty()) {
              System.exit(0);
          }
  
          else {  
  
              Calendar c = Calendar.getInstance();
  
              String[] days = new String[] {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
  
              System.out.println("Day of week is " + days[c.get(Calendar.DAY_OF_WEEK) - 1]);
  
              System.out.println("Repeatedly enter a date (m d y) to get the day of week. Terminate input with a blank line.");
              date = s.nextLine();
          }
        }
      }
    }
  </code></pre>
  
  <p>I know what needs to be replaced is the second to last chunk of code that says c.get(Calendar.DAY_OF_WEEK), however I do not know what I can use to replace it in order to get the user inputted date.</p>
  
  <p>I know there are other packages that can solve the same problem, however, I'm required to use the Calendar class whether I like it or not.</p>