I set the time for my calendar instance as follows
private Calendar mCalendar = Calendar.getInstance();
public void onTimeSet(int hourOfDay, int minute, int second) {
int year = mCalendar.get(Calendar.YEAR);
int monthOfYear = mCalendar.get(Calendar.MONTH);
int dayOfMonth = mCalendar.get(Calendar.DAY_OF_MONTH);
Calendar lCalendar = Calendar.getInstance();
lCalendar.set(year, monthOfYear, dayOfMonth, hourOfDay, minute);
Date lDate = lCalendar.getTime();
if (lDate.before(new Date())) {
return;
} else {
mCalendar.set(year, monthOfYear, dayOfMonth, hourOfDay, minute);
setItemTime();
}
}
However, when I call getTime () on instances of Calendar lCalendar and mCalendar, I get the time at which the calendar was not created from hourOfDayand the minutearguments set in the instances of the calendar. Also, if I call the method again getTime()in both cases, I get the correct time.
Why is this happening and how can I solve it?
Harry source
share