title: Checking dates if it is in a range
body: <p>My Java FX app handles hours worked. I have work start and end time in 2 date fields. I succeeded in calculating the differences between 2 datesTime; but now how could I check if the result is in a night or day range???? The day begin at 6 and ends at 22h. For example someone who worked between 3Am till 11Pm.
  Here is below how I did to have the total number of hours worked.</p>
  
  <pre><code>public void CalculNbreJourTravaille() {
      SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyy HH:mm");
  
      try {
          Date ddtt = format.parse(ddt.getText());
          Date dftt = format.parse(dft.getText());
          long diff = dftt.getTime() - ddtt.getTime();
          long diffhours = diff / (60*60*1000)%24;
          long diffdays = diff/(24*60*60*1000);
          long total = diffhours + (diffdays*24);
          result.setText(total + " Hours");   
      } catch (ParseException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>We have workers who can work beyond 10PM, and the pay would not be the same. If they work after 10pm, they will have a special pay. We pay at the end of the work. They could would work only 10 days or more.</p>