Marat Marat - 1 year ago 146
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:




Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download