title: Create a Java Date from a String and vise versa
body: <p>I have a <code>date</code> in <code>Integer format</code><strong>(YYYYMMDD)</strong>. And a <code>start_time</code> as a <code>String</code> <strong>(HH:mm 24 hour system)</strong>. and a <code>time_duration</code> in <strong>hours</strong> as a <code>double</code>.</p>
  
  <pre><code>int date = 20140214;
  String start_time = "14:30";
  double duration = 50.30;
  </code></pre>
  
  <p>I want to use these 3 values and create 2 Java Date Objects. One is <code>start_date</code> and one is <code>end_date</code>. They should be in the format <code>YYYY-MM-DD HH:mm</code>.</p>
  
  <p>And then after I get 2 data Strings like  <code>YYYY-MM-DD HH:mm</code>. how can I obtain those previous variables. <code>date</code>, <code>start_time</code>, <code>duration</code>. </p>
  
  <p>This is my attempt.</p>
  
  <pre><code>public void solve() throws IOException {
      int date = 20140214;
      String start_time = "14:30";
      double duration = 24.50;
      String startDate = "";
      DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
      startDate = getDate(date) + " " + start_time;
      try {
          Date start_Date = df.parse(startDate);
          Date end_Date = new Date(start_Date.getTime()+(int)(duration*3600*1000));
          System.out.println(df.format(start_Date));
          System.out.println(df.format(end_Date));
  
      } catch (ParseException ex) {
  
      }
  
  }
  public String getDate(int dateInt) {
      String date = "";
      String dateIntString = String.valueOf(dateInt);
      date = date + dateIntString.substring(0, 4) + "-";
      date = date + dateIntString.substring(4, 6) + "-";
      date = date + dateIntString.substring(6, 8);
      return date;
  }
  </code></pre>
  
  <p>Is there any easy way to do it. ? Or some built-in capabilities I can use other than those I have used ?</p>