Most of the methods e.g. getYear()
getMonth()
are depricated and mentions to use Calendar.get(Calendar.MONTH)
instead.
However, as mentioned here, in order to do that, we would need to write:
Calendar cal = Calendar.getInstance();
cal.setTime(date);
Also, Calendar.getInstance()
does not return same instance of Calendar, but returns a new instance always.
Is there a faster way to get Year, Month, Day, etc from Date, instead of creating Calendar instance and setting date and then getting the required information?
In other words, is there any more performant way to achieve so?