Java – Is Calendar.getInstance().getTime() Different from new Date()?

java

I'm trying to consolidate some code that is very messy but I want to make sure I don't break things. In some places I see a date created as Calendar.getInstance().getTime() and in others it's just new Date(). Will it break things if I convert them all to new Date() or is there some reason I may want to use the other?

Best Answer

In theory, no, because both java.util.Date and java.util.Calendar.getInstance() eventually use System.currentTimeMillis() to return the current time.

The Calendar implementation, however, takes other things into consideration, like the Locale, or if the locale is JP or TH... you can see that in the source code of both classes.