title: Parse date/time from string?
body: <p>I'm trying to create a program to parse a meaningful date and time from a string. I want to be able to give the following kinds of input, and create a date/time object:</p>
  
  <pre><code>5 o'clock
  5 p.m.
  5 a.m.
  5
  530
  530 a.m.
  530 p.m.
  Tuesday at [insert any above string here]
  the 30th at [same as above]
  May 12th at [same as above]
  today at [same as above]
  tomorrow at [same as above]
  </code></pre>
  
  <p>Any string that doesn't contain a day/date can be assumed as being today, and any time that does not have an AM/PM designation can be assumed as occuring between 9AM and 8:59PM.
  I quickly realized what a mess this was becoming after writing this portion of code:</p>
  
  <pre><code>private void createEvent(String phrase) {
      int hour;
      int day = 0;
      String dayOfWeek = "";
  
      if (phrase.contains("o'clock")) {
          hour = Integer.parseInt(phrase.substring(phrase.indexOf("o'clock")-3, phrase.indexOf("o'clock")-1).trim());
          out.write(""+hour);
      }
  
      if (phrase.contains("tomorrow"))
          day = (Calendar.DAY_OF_WEEK % 7)+1;
  
      if (phrase.contains("sunday") || day == 1) {
          dayOfWeek = "Sunday"; day = 1; }
      else if (phrase.contains("monday") || day == 2) {
          dayOfWeek = "Monday"; day = 2; }
      else if (phrase.contains("tuesday") || day == 3) {
          dayOfWeek = "Tuesday"; day = 3; }
      else if (phrase.contains("wednesday") || day == 4) {
          dayOfWeek = "Wednesday"; day = 4; }
      else if (phrase.contains("thursday") || day == 5) {
          dayOfWeek = "Thursday"; day = 5; }
      else if (phrase.contains("friday") || day == 6) {
          dayOfWeek = "Friday"; day = 6; }
      else if (phrase.contains("saturday") || day == 7) {
          dayOfWeek = "Saturday"; day = 7; }
      else {
          dayOfWeek = "Today"; day = 0; }     
  }
  </code></pre>
  
  <p>Can anyone provide some direction?</p>