Wanted to know more about Calendar.getInstance()
. I can create Date instance with constroctor, but why not a Calendar instance? Why Calendar
designed to use a factory method and why it has been abstract class.
Please share the reason behind it.
My Question is very simple: If we have new operator on Date class, why not for Calender. what was the idea behind a static method to create instance.
Many Thanks,
There are different Calendar implementations. Calendard.getInstance() is locale sensitive and returns the suitable implementation for the country of your default locale.
The documentation says: "The Calendar returned is based on the current time in the default time zone with the default locale."
According to source code you get a BuddhistCalendar for language "th" and country "TH" or a JapaneseImperialCalendar for Japan with variant "JP". Otherwise you get a GregorianCalendar instance.
You are free to create a GregorianCalendar instance with its constructor.