I’m trying the harder challenge and thought I’d use DatePickerFragment as a model. I thought I understood the code, but I’m puzzled by something.
In it we find:
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH);
int day = calendar.get(Calendar.DAY_OF_MONTH);
What is setTime(mDate) doing there? Should we be getting the time from the mDate?
However, later on in the code we find:
mDate = new GregorianCalendar(year, month, day).getTime();
Which I’m interpreting as building up mDate from the revised information. What is getTime() doing there? Wouldnt it be getting the current date and time? Wouldnt we want the date that came along when mDate was entered as an argument?
It’s as if, to me anyway, get/set are reversed.
I tried to read and developers documentation but that didnt help. I’m obviously confused.