I set an alarm for which I accept Hour and Minutes from TextViewand AM / PM through Spinner. This is how I initialize the object Calendar:
Calendar calen = Calendar.getInstance();
calen.set(Calendar.HOUR_OF_DAY, alarmHour);
calen.set(Calendar.MINUTE, alarmMinute);
calen.set(Calendar.SECOND, 0);
calen.set(Calendar.MILLISECOND, 0);
if(amorpm.equals("PM")
{
calen.set(Calendar.AM_PM, Calendar.PM);
}
else
{
calen.set(Calendar.AM_PM, Calendar.AM);
}
The problem is that the Hour value of this object is Calendarsometimes correct, that is, the value that the user enters in TextView(and it is always from 1 to 12). But sometimes the value is equal to the current Hour. For example, if the current time is 11:30 in the evening , and I set the alarm for 9:30 in the morning , then the Hour field is 11 . It is strange that when I change the name of an object Calendarto something else, say cal , it works. But I will not work later. What could be wrong?
Thank you for your help!
source
share