本帖最后由 付信榕 于 2012-6-11 21:18 编辑
找到src里的源代码
public static Calendar getInstance(TimeZone zone, Locale aLocale)
{
return createCalendar(zone, aLocale);
}
private static Calendar createCalendar(TimeZone zone,
Locale aLocale)
{
Calendar cal = null;
String caltype = aLocale.getUnicodeLocaleType("ca");
if (caltype == null) {
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 {
cal = new GregorianCalendar(zone, aLocale);
}
return cal;
}
可以看到getInstance()返回的GregorianCalendar的对象或者是BuddhistCalendar的对象(明显这两个类都不是抽象类)并不是由抽象类Calendar new的对象。所以可以用Calendar rightNow = Calendar.getInstance();来获得一个实例化对象。
|