Hi, whilst reading a book on Java, I came across a bit where the author used

GregorianCalendar now = new GregorainCalendar();

And I was just wondering, is that any different from

Calendar now = Calendar.getInstance();

And if so, why did he use GregorianCalendar instead of the normal one?

try this web link and read the comments at top:


essentially as it says:

This implementation handles a single discontinuity, which corresponds by default to the date the Gregorian calendar was instituted (October 15, 1582 in some countries, later in others). The cutover date may be changed by the caller by calling setGregorianChange().

// end quote

I think this would be useful if you have an application that uses historical time. One method is i'm going to feed you dates based on how we understand the calander works now with that date of change over, the gregorian seems to say if we are in a period of history were they may or may not have used gregorian time i can handle it. The calander before gregorian ( what we use now ) was julian which can be off a few days as you go back centuries do to slightly different leap year rules. i think they ommit skipping a leap year every 400 years in julian.


GregorianCalendar(concrete class) is a subclass of Calendar(abstract class).So u can use either....So u can say GregorianCaendar c=new GregorianCalendar.......thanks