title: How to compare current time with time range?
body: <p>I have two String variables - <code>time1</code> and <code>time2</code>. Both contain value in the format <em>HH:MM</em>. How can I check:</p>
  
  <ol>
  <li>If the current time is within
  <code>time1</code> and <code>time2?</code></li>
  <li><code>time1</code> will happen in the nearest
  hour?</li>
  </ol>
  
  <p><strong>Upd.</strong>
  I've implemented the following to convert <code>time1</code> to <code>Date</code> format. But it uses depreciated methods:</p>
  
  <pre><code>Date clTime1 = new Date();
  
  SimpleDateFormat timeParser = new SimpleDateFormat("HH:mm", Locale.US);
  try {
    clTime1 = timeParser.parse(time1);
  } catch (ParseException e) {
  }
  
  Calendar now = Calendar.getInstance();
  clTime1.setYear(now.get(Calendar.YEAR) - 1900);
  clTime1.setMonth(now.get(Calendar.MONTH));
  clTime1.setDate(now.get(Calendar.DAY_OF_MONTH));
  System.out.println(clTime1.toString());
  </code></pre>