Android Dev: Current Time range check
<p>I'm working on an android application, as part of me trying to learn android programming, that will switch audio profiles based on day and time (provided by the user)... So far I have got most of the layout done, I have also created a service that will run in the background to perform few checks...</p>

<p>Right now I'm having a hard time trying to find an elegant way to handle checking if current time falls in time range saved by the user... I'm saving the user's preference for time range in a string format from androids TimerPicker control, I need to check if the current time falls in the user saved times...</p>

<p>Right now I have the following code:</p>

<p>the 'from time' is coming in with the following: hour:minute:AM/PM -- 8:59:AM in string format</p>

<p>the 'to time' is coming in with the following: hour:minute:AM/PM -- 4:59:PM in string format</p>

<pre><code>if(fromAMPM.equals("AM")){
        from.set(from.AM_PM, from.AM);
} else {
        from.set(from.AM_PM, from.PM);
}

//dont care about the YEAR and MONTH, so set it to current MONTH and YEAR                                      
from.set(rightNow.get(rightNow.YEAR), rightNow.get(rightNow.MONTH), dayOfWeek, fromHour, fromMinute);                  

if(toAMPM.equals("AM")){
        to.set(to.AM_PM, to.AM);
}else{
        to.set(to.AM_PM, to.PM);
}      

//dont care about the YEAR and MONTH, so set it to current MONTH and YEAR                      
to.set(rightNow.get(rightNow.YEAR), rightNow.get(rightNow.MONTH), dayOfWeek, toHour, toMinute);

//this is just for me to see what got set:
SimpleDateFormat df3 = new SimpleDateFormat("HH:mm aaa");  
String formattedDate1 = df3.format(from.getTime());
String formattedDate2 = df3.format(to.getTime());
</code></pre>

<p>After all this processing:</p>

<pre><code>formattedDate1 is returning: 08:59 AM

formattedDate2 is returning: 04:59 AM
</code></pre>

<p>Any suggestions?</p>

<p>Thanks</p>
