title: SWT DateTime - read date and time from two widgets
body: <p>Imagine two widgets:</p>
  
  <pre><code>DateTime dtDate = new DateTime(parent, SWT.BORDER);
  </code></pre>
  
  <p>and</p>
  
  <pre><code>DateTime dtTime = new DateTime(parent, SWT.BORDER | SWT.TIME);
  </code></pre>
  
  <p>Would would be the most efficient way to read date and time from the two widgets into a single Date variable?</p>
  
  <p><strong>Edit</strong>:
  The following solution that I have in mind is far from being elegant. I hope that there is a better way to do this.</p>
  
  <pre><code>final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  // year
  dateString += String.valueOf(dtDate .getYear());
  dateString += "-";
  // month
  dateString += String.valueOf(dtDate .getMonth());
  dateString += "-";
  
  // day
  dateString += String.valueOf(dtDate .getDay());
  dateString += " ";
  
  // hour
  dateString += String.valueOf(dtTime.getHours());
  dateString += ":";
  
  // minute
  dateString += String.valueOf(dtTime.getMinutes());
  dateString += ":";
  
  // second
  dateString += String.valueOf(dtTime.getSeconds());
  
  try {
      Date startDate = (Date) dateFormat.parse(dateString);
      } catch (ParseException exception) {
      exception.printStackTrace();
      }
  </code></pre>