This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "calendar.getInstance()" Watch "calendar.getInstance()" New topic
Author

calendar.getInstance()

sivaramp pratapa
Greenhorn

Joined: Jul 05, 2003
Posts: 11
Hi
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. .
thanks
siva
Alton Hernandez
Ranch Hand

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

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: http://aspose.com/file-tools
 
subject: calendar.getInstance()
 
Similar Threads
public abstract class Calendar
GreogorianCalendar!? how to work it out
Abstract Classes
Why they have named a calendar method like this?
How to get the current time in java?