File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes calendar.getInstance() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "calendar.getInstance()" Watch "calendar.getInstance()" New topic


sivaramp pratapa

Joined: Jul 05, 2003
Posts: 11
calendar.getInstance() returns a calendar object,
why is that!
calendar is an abstract class..
so, where from this returns a calendar object!
can you guys throw some light on this!
please. .
Alton Hernandez
Ranch Hand

Joined: May 30, 2003
Posts: 443
It is because getInstance() is a static method.
Consider this code. Compile it and run it and see what happens.
George Hill

Joined: Aug 26, 2003
Posts: 6
Hi, look the java source.You will get it.
* Gets a calendar with the specified time zone and locale.
* The <code>Calendar</code> returned is based on the current time
* in the given time zone with the given locale.
* @param zone the time zone to use
* @param aLocale the locale for the week data
* @return a Calendar.
public static Calendar getInstance(TimeZone zone,
Locale aLocale)
return createCalendar(zone, aLocale);
private static Calendar createCalendar(TimeZone zone,
Locale aLocale)
if (aLocale.getLanguage().compareTo("th") == 0) {
if (aLocale.getCountry().compareTo("TH") == 0) {
return new sun.util.BuddhistCalendar(zone, aLocale);
// else create the default calendar
return new GregorianCalendar(zone, aLocale);
I agree. Here's the link:
subject: calendar.getInstance()
It's not a secret anymore!