Hey Phyll,
Thanks for the reply and the chunk of code...actually shortly after i posted here, i went back n re-read the Calendar documentation on android's website...and i realized that i kept missing the part that the .set(...) took 24 hour and by me passing in the data i was passing in, it was dropping off the AM/PM due to invalid data...never-the-less, i still wasnt able to get the .set(...) to work despite few attempts...so what i ended up doing instead was to set the hour, minute, second separately...
i have that working so far, but i was wondering if you can provide input on this other issue i am having some trouble with...basically, i have this timer code, and im calculating the next time when the timer code is suppose to execute after the 'current time' falls within the user's saved profile 'from' and 'to' time ranges...
the issue is that the timer code is using a nextUpdateInterval variable that is being calculated each time a profile is found...but when the profile time spans over midnight into the next day im unable to find a proper formula to calculate the nextUpdateInterval...im still trying to figure out how to account/calculate time that spans over to the next day, and at this point im starting to think that im might be making this task overly complicated? any suggestions?
here is the chuck of code that im working with as of now:
- Code: Select all
timer.scheduleAtFixedRate( new TimerTask() {
public void run() {
//..... some code to convert user stored times into proper time formats
//PM to PM
if(isFromTimePM == true && isToTimePM == true){
}//PM to AM
else if(isFromTimePM == true && isToTimePM == false){
if(rightNowDate.getTime() >= fromDate.getTime() && rightNowDate.getTime() >= toDate.getTime()){
foundProfileIndex = i;
i = profileArrayListSize;
nextUpdateInterval = rightNowDate.getTime() - toDate.getTime(); //toDate.getTime() - fromDate.getTime();
}
}//AM to AM
else if(isFromTimePM == false && isToTimePM == false){
}//AM to PM
else if(isFromTimePM == false && isToTimePM == true){
}}, 0, nextUpdateInterval);
Thanks again!