Question 2

Posted Thursday, September 03, 2009 by SacrosanctBlood in

How many concrete implementations of the java.util.Calendar are released
in your JDK?

1.    ONE: the Gregorian Calendar
2.    TWO: the Gregorian Calendar and a new one from Japan
3.    THREE: because there is secret Calendars somewhere
4.    None of the above



1 comment(s) to... “Question 2”

1 comments:

SacrosanctBlood said...

If you ask this for a specific version of the JDK, perhaps I can guess
how many calendars you have available - but the generic answer considers
it is dependent of the JDK version, and probably also dependant on
particular revisions of JDK nightly builds.



public static void main(String[] args) {
// JDK 1.5: This is the hidden Buddhist bug
Calendar budish = Calendar.getInstance(new Locale("th",
"TH"));
System.out.println(budish.getClass());

// JDK 1.6: This is the undocumented Imperial mistake
Calendar japanese = Calendar.getInstance(new Locale("ja",
"JP", "JP"));
System.out.println(japanese.getClass());

// Any JDK: nobody really knows about the type -
suposedely Gregorian
Calendar suposeGregorian = Calendar.getInstance();
System.out.println(suposeGregorian.getClass());
}



Output:

class sun.util.BuddhistCalendar
class java.util.JapaneseImperialCalendar
class java.util.GregorianCalendar



Post a Comment