title: Java - Convert String variable to Date + get today's date in format MM/dd/yyyy
body: <p><strong>Quick Background:</strong></p>
  
  <p>I have created a GUI for a reservation application in Eclipse. On it, I have multiple combo boxes for arrival and departure dates (month, day, year - for both). I have retrieved the information and tied it to a String variable so it appears as something like this: 12/04/2014. </p>
  
  <p><strong>The Questions:</strong></p>
  
  <ol>
  <li>What is a good way to convert that string (arrival/departure) to Date datetype for comparison purposes? I will need to verify the arrival is not before today's date and get the length of stay.</li>
  <li>What is a good way to retrieve today's date like so - 2/19/2014.</li>
  </ol>
  
  <p>I have been searching the internet for quite a while but can't seem to find anything clear.</p>
  
  <p>Please do not recommend any add-ons or interface tools as I must code this all by hand with only what is readily available (if that makes sense).</p>
  
  <p>Thank you!</p>
  
  <p><strong>--- EDITS ---</strong></p>
  
  <p>I have tried many of the things mentioned below ...</p>
  
  <ol>
  <li><p>'Date today = new Date()' gives me a red line under new Date() asking for an argument of int or long. </p></li>
  <li><p>Below is the code I have when I assemble my date from the combo boxes. dateFormat.parse(holder) gets a red underline  prompting to add throws declaration or surround with try/catch. The datatypes for the variables below are ... index (int). holder (String). arrival/departure (java.util.Date) -- for whatever reason it won't accept Date even with that imported, although it does in my Hotel class. Strange, yes, but not my main focus.</p>
  
  <pre><code>    // Assignments
  index = view.getArriveMonthIndex() + 1; // Arrival date
  holder = index + "/" + view.getArriveDay() + "/" + view.getArriveYear();
  arrival = dateFormat.parse(holder);
  
  index = view.getDepartMonthIndex() + 1; // Departure date
  holder = index + "/" + view.getDepartDay() + "/" + view.getDepartYear();
  departure = dateFormat.parse(holder);
  </code></pre></li>
  </ol>
  
  <p>Something else to perhaps mention/show .. at the very beginning of my class, this is a bit of what I have been playing around with/tried.</p>
  
  <pre><code>DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy", Locale.US);
  Calendar todaysDate = Calendar.getInstance();
  String today = dateFormat.format(todaysDate.getTime());
  </code></pre>
  
  <p>^^ Just tested this last part, it works. </p>
  
  <p>I went ahead with the underlined suggestions for my arrive/departure variables. My method now throws a ParseException. Haven't been able to locate a good description for this - what exactly is its point? (very much new if you couldn't tell) -- BACKUP. Changing that back to how it is above. This way requires a throw/catch around my call to the reserveHotel() method.</p>