title: Calculating time difference in hours
body: <p>I am a newbie in java. I have written this function to find the time difference in hours from the current time to the time in function parameters. The results are kind of mixed, how I can I improve it? Thanks.</p>
  <pre><code>private int getTimeDiffFromCurrent(String date, String time)
      {
          String str_date_time = date + &quot; &quot; + time;
          DateFormat formatter = new SimpleDateFormat(&quot;dd/MM/yyyy HH:mm:ss&quot;, Locale.getDefault());
  
          try {
              Date date_time = (Date) formatter.parse(str_date_time); 
              int hr = (int)((System.currentTimeMillis() - date_time.getTime())/(1000 * 60 * 60));
              return hr&gt;=0? hr : 1000;
          }
          catch (Exception e) {
              System.out.println(e.toString() + &quot;, &quot; + str_date_time);
          }    
          return 1000;
      }
  </code></pre>
  <p>Example of used case:</p>
  <p><code>getTimeDiffFromCurrent(&quot;19/07/2020&quot;, &quot;07:19:00&quot;);</code></p>