日期:2014-05-20  浏览次数:20730 次

Calendar.getInstance()
小弟是个java初学者,有几个关于Calendar这个类的问题请教大侠,望解决
1.为什么sun把Calendar设计成抽象的类
2.是怎么通过getInstance()这个方法创建出一个Calendar对象的,能不能给我发一下getInstance()这个方法的源码或者大侠给我讲解一下也行
拜谢
------解决方案--------------------
    /**
     * 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());
cal.sharedZone = true;
return cal;
    }


粗略看了下 ,使用getInstance()是为了传入Calendar的子类的实例。。。