title: How do I measure time elapsed in Java?
body: <p>I want to have something like this:</p>
  
  <pre><code>public class Stream
  {
      public startTime;
      public endTime;
  
      public getDuration()
      {
          return startTime - endTime;
      }
  }
  </code></pre>
  
  <p>Also it is important that for example if the startTime it's 23:00 and endTime 1:00 to get a duration of 2:00.</p>
  
  <p>Which types to use in order to accomplish this in Java?</p>