查看源码后得之,是由子类实现的实例,具体源码如下:- public static Calendar getInstance()
- {
- Calendar cal = createCalendar(TimeZone.getDefaultRef(), Locale.getDefault(Locale.Category.FORMAT));
- cal.sharedZone = true;
- return cal;
- }
复制代码 然后去找createCalendar方法的内容,代码如下:- private static Calendar createCalendar(TimeZone zone,
- Locale aLocale)
- {
- Calendar cal = null;
- String caltype = aLocale.getUnicodeLocaleType("ca");
- if (caltype == null) {
- // Calendar type is not specified.
- // If the specified locale is a Thai locale,
- // returns a BuddhistCalendar instance.
- if ("th".equals(aLocale.getLanguage())
- && ("TH".equals(aLocale.getCountry()))) {
- cal = new BuddhistCalendar(zone, aLocale);
- } else {
- cal = new GregorianCalendar(zone, aLocale);
- }
- } else if (caltype.equals("japanese")) {
- cal = new JapaneseImperialCalendar(zone, aLocale);
- } else if (caltype.equals("buddhist")) {
- cal = new BuddhistCalendar(zone, aLocale);
- } else {
- // Unsupported calendar type.
- // Use Gregorian calendar as a fallback.
- cal = new GregorianCalendar(zone, aLocale);
- }
- return cal;
- }
复制代码 由上面两段代码,可以看出是由子类实现的 |