title: Calculating with time differences
body: <p>Obviously, there are already threads about calculating with time in Java.</p>
  
  <p>However, my question goes a little bit further.
  What I want to do:</p>
  
  <ul>
  <li>Calculating difference between beginning and ending time (ALREADY DONE)</li>
  <li>Adding this difference back to the beginning time</li>
  </ul>
  
  <p>An example:<br>
  Paul started working at 4:00 and ended at 9:00 
  I want it to return 6:30 (4 + (9-4)/2)</p>
  
  <p>My code yet:</p>
  
  <pre><code>for (int i = 1, n = licenseplateList.size(); i &lt; n; i++) 
  {               
      //first look at whether it is considered as day or night time               
      try {
      String time1 = begintimeList.get(i);
      String time2 = endingtimeList.get(i);
  
      SimpleDateFormat format = new SimpleDateFormat("HH:mm");
      Date date1 = format.parse(time1);
      Date date2 = format.parse(time2);
      long average = ((date2.getTime() - date1.getTime())/2);
  
      System.out.println(average);
  
  
      }catch (Exception e) {
      }
  </code></pre>
  
  <p>Edit:<br>
  I also want to know how I afterwards can decide whether it's day or night time (i want to use beginning + ending, because if that's over 18:00 I'll consider it nigh time). However, how can I do this in an ifstatement?</p>