Instead of using Calendar
instances for mCalendarOpeningTime
and mCalendarClosingTime
, why dont you use them as Date
instances?? that'll be more efficient and might as well get your code up and running.
EDIT:- ok.. forget whats written above.. It was crap.. :P following the piece of code that will do what you want to achieve:-
First up.. set the mCalendarOpeningTime
and mCalendarClosingTime
something like this and call this method in onCreate()
or onStart()
so that the values are assigned to the respective "times" before you start using them:-
private void setOpeningAndClosingTimes() {
mCalendarOpeningTime = Calendar.getInstance();
mCalendarOpeningTime.set(Calendar.HOUR, 11);
mCalendarOpeningTime.set(Calendar.MINUTE, 30);
mCalendarClosingTime.set(Calendar.AM_PM, Calendar.AM);
mCalendarClosingTime = Calendar.getInstance();
mCalendarClosingTime.set(Calendar.HOUR, 10);
mCalendarClosingTime.set(Calendar.MINUTE, 00);
mCalendarClosingTime.set(Calendar.AM_PM, Calendar.PM);
}
your comparison is good enough.. try this and let me know if it worked or not...