title: Get partial seconds difference from timestamps
body: <p>I have a code that basically logs data, as of now everything seems to be working fine except I am having issues getting the difference between two time stamps:</p>
  
  <pre><code>System.out.println(readings.size());
      displayLog.appendText("Getting ready to print! Beep Boop! \n" );
  
              for (int t = 0; t &lt; readings.size(); t++)
      {
          displayLog.appendText("Time: " + readings.get(t).getTimestamp() + " CH1: " + readings.get(t).getValue(0) + " CH2: " + readings.get(t).getValue(1) + " CH3: " + readings.get(t).getValue(2) + " CH4: " + readings.get(t).getValue(3) + " CH5: " + readings.get(t).getValue(4) + " CH6: " + readings.get(t).getValue(5) + " CH7: " + readings.get(t).getValue(6) + " CH8: " + readings.get(t).getValue(7) + " CH9: " + readings.get(t).getValue(8) + "\n");
      }
              int maxReading = readings.size() - 1;
              displayLog.appendText(readings.get(0).getTimestamp() + "\n");
              displayLog.appendText(readings.get(maxReading).getTimestamp() + "\n");
  
              Duration timeDifference = Duration.between(readings.get(0).getTimestamp(), readings.get(maxReading).getTimestamp());
  
              displayLog.appendText("Time difference is: " + timeDifference.getSeconds() + "\n");
  </code></pre>
  
  <p>Whenever I run the code I get an interger, is there a way to get like a double with partial seconds displayed?
  Say 6.3 seconds or 8.8 seconds instead of 6 and 9. I dont even know if it rounds up or rounds down or truncates or what does it do when it returns this value? or is there a better way to get time difference?</p>
  
  <p>The timestamps get logged by pressing a button using timeStamp LocalDateTime.now()</p>
  
  <p>I tried this code to print and see but I get inconsisten results:</p>
  
  <pre><code>    int maxReading = readings.size() - 1;
      Duration timeDifference = Duration.between(readings.get(0).getTimestamp(), readings.get(maxReading).getTimestamp());
      double secondsDifference = timeDifference.getNano() / 1000000000;
      textLog.appendText("Total time logged is: " + secondsDifference + "\n");
      System.out.println(timeDifference.getSeconds() + "  |  " + secondsDifference + "  |  " + timeDifference.getNano());
      System.out.println("Time logged: " + secondsDifference);
  </code></pre>
  
  <p>However, this gives out the following output, which does not make sense (IMO):</p>
  
  <pre><code>4  |  0.0  |  270000000
  Time logged: 0.0
  </code></pre>
  
  <p>Like, according to this it logged for 4 seconds? or for 270000000 nanoseconds?
  or is it actually 4.27 seconds?</p>