• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

calendar.getInstance()

 
sivaramp pratapa
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 443
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
It is because getInstance() is a static method.
Consider this code. Compile it and run it and see what happens.
 
George Hill
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);
}
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic