/**
* gets a calendar using the default time zone and locale. the
* <code>calendar</code> returned is based on the current time
* in the default time zone with the default locale.
*
* @return a calendar.
*/
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;
}