I just stumbled accross this method
public static Date getNowDate() {
final Calendar cal = new GregorianCalendar();
cal.setTime(new Date());
return cal.getTime();
}
which gets called like this:
getNowDate().getTime()
Is this any different from just calling
System.currentTimeMillis()
?
They are all much the same except for performance.
System.currentTimeMillis() is a system call so it takes around 0.1 to 0.3 micro-seconds (depending on your OS)
new Date() also creates an object, which takes only about 0.1 to 0.3 micro-seconds more but creates a little garbage.
Calendar.getInstance() creates an expensive set of objects and takes about 33 micro-seconds more.