title: How to set Java.util.calendar to a specific time period in the future
body: <p>I'm using Java's calendar to set an alarm at a specific date and time. I know how to make this work when the user selects a <em>specific</em> date and time. For example, if the user wants to set an alarm on July 17th, 2013 at 10:45AM, I'm using the following code:</p>
  
  <pre><code>//Get the calendar instance.
  Calendar calendar = Calendar.getInstance();       
  
  //Set the time for the notification to occur.
  calendar.set(Calendar.YEAR, 2013);
  calendar.set(Calendar.MONTH, 6);
  calendar.set(Calendar.DAY_OF_MONTH, 17);                 
  calendar.set(Calendar.HOUR_OF_DAY, 10);
  calendar.set(Calendar.MINUTE, 45);
  calendar.set(Calendar.SECOND, 0);
  </code></pre>
  
  <p>All of the above code works really well when I want to set an alarm at a <strong>specific date and time</strong>. My question is, how can I set a calendar instance where the user user wants an alarm to go off 20 minutes from the current date and time? So if the current time is 6:50PM, I need the alarm to go off at 7:10PM. How can I set this programmatically?</p>
  
  <p>I tried to get the current date and time via the Java.util.calendar's built-in methods and tried adding 20 minutes to the <code>Calendar.MINUTE</code> variable. However, I don't think this will do the trick if the current time is less than 20mins away from midnight (the date will change), or 20mins away from another hour (the hour will change). How can I get around this problem? Thanks for all your help!</p>