Jeremy Cron Jeremy Cron - 28 days ago 7
Java Question

Is calling Java's Calendar.getTime() necessary to update the object?

I came across a comment in some java code that states that

getTime()
needs to be called to update the
Calendar
object. Is this true? I cannot find anything that says that this is necessary.

Here's the code:

Calendar cal = new GregorianCalendar();
cal.setFirstDayOfWeek(Calendar.SUNDAY);
cal.set(2009, 9 - 1, 10, 2, 30);
// Get Time needs to be called to update the Calendar object
cal.getTime();

Answer

No, this is not true.