Marat Marat - 6 months ago 13
Java Question

What is the difference between getTimeInMilis() and .getTime().getTime()?

Let's say I have a Calendar object c. What will be the result of this lines:

c.getTimeInMilis();


and

c.getTime().getTime();

Answer

Ostensibly they are identical.

But I'd plump for the first one since it does not create (explicitly) a java.util.Date temporary.

c.getTimeInMilis(); is also more descriptive.

Personally I dislike "chained" functions statements in Java (i.e. things like a.b().c().d();) since they tend to be where NullPointerException possibilities tend to lurk.