Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!

Problem with Gregorian Calendar BC Date

prakash Venkatesan
Greenhorn
Posts: 2
For a BC Date in Gregorian Calendar,if the year is leap year
i am not able to store the date 29 for month of February,
if i am trying to store '29-2-2004' for BC date it is conveting
in to '1-3-2004', this is not the problem for AD dates,for AD dates it is
working fine,the problem is only with BC Dates,can anyone clear this for me

Nathan Pruett
Bartender
Posts: 4121
Since this doesn't have anything to do with Swing/JFC/AWT GUI stuff, I'm moving this post to the Java In General - Intermediate forum.

Also, the reason for this is probably due to the fact that to calculate a leap year in the present, future, or recent past all you need is the formula that a leap year is a year divisable by 4, but not 100, unless it is also divisible by 400. However, if you go far into the past, you also have to apply historical knowledge that doesn't follow a formula. Prior to October 15, 1582 dates you get from the GregorianCalendar class will actually use the Julian calendar instead. The Julian calendar also has leap years, and they are (were?) calculated similarly to the Gregorian calendar. However, the concept of the leap year was only introduced in 46 BC, and there's a gap between 9 BC and 8 AD due to making up for miscalculations early on. (Most of this information was gleaned from this page.)

So, 2004 BC would not be a leap year because leap years did not exist at that point. (err.. well... at least as a concept.)