title: How to Read Time and Date from Text File in Java 5?
body: <p>I'm trying to read data from a plain text file using Java 5 SE. The data is in the following formats:</p>
  
  <pre><code>10:48 AM
  07/21/2011
  </code></pre>
  
  <p>I've looked into DateFormat and SimpleDateFormat, but I can't figure out the most straight-forward way of reading this data into a Date object.</p>
  
  <p>Here's what I have so far:</p>
  
  <pre><code>import java.io.File;
  import java.io.BufferedReader;
  import java.io.FileReader;
  import java.io.IOException;
  import java.text.SimpleDateFormat;
  import java.util.Date;
  
  class Pim {
  
      File dataFile;
      BufferedReader br;
      String lineInput;
      Date inputTime;
      Date inputDate;
  
      public Pim() {
  
          dataFile = new File("C:\\Data.txt");
  
          try {
  
              br = new BufferedReader(new FileReader(dataFile));
  
              lineInput = br.readLine();
              inputTime = new Date(lineInput);
  
              lineInput = br.readLine();
              inputDate = new Date(lineInput);            
  
              br.close();
  
          } catch (IOException ioe) {
  
              System.out.println("\n An error with the Data.txt file occured.");
          }
      }
  }
  </code></pre>
  
  <p>Am I on the right track here? What's the best way to do this?</p>