编写与历史或历法有关的程序时,JDK提供的GregorianCalendar类非常好用,它可以很好地再现奥古斯督修订后的儒略历以及1582年教皇改历后的格列高里历,即,1582年10月4日以前按儒略历规则处理,1582年10月15日以后按格列高里历处理,格列高里改历时隐去的10天也能正确处理(甚至可以针对西欧各国改历的先后,自行设定不同的改历时间GregorianCalendar.setGregorianChange())。
但GregorianCalendar类仍有其适用范围,它无法反映古罗马历法中,公元前45年至公元4年这一段时间内发生的历法混乱问题(这49年里古罗马历法远未完善,且史料不足,实际施行的历法难以考证,后人的研究结果也互有分歧)。比如,按照史学界最常见的一种看法,公元4年罗马未置闰年,该年2月仍是28天。但我们用GregorianCalendar类计算时,公元4年2月有29天。
如何处理这个问题,取决于你的关注点。如果你只想用一个通行的时间尺度去标定过去的事件,那你完全可以用GregorianCalendar类上推到任何一年。其实,当研究对象与人类历史或人类社会无关时,仅仅用格列高里历上推,而不考虑1582年以前的历法差异(主要差异在于百年置闰的方式)也是一种变通的方案。但是,如果你关心的是古罗马或与之相关的历史事件,或你希望以罗马实际施行的历法为参照系,你就必须为GregorianCalendar类引入修正代码。当然,如何修正,这还要取决于你对古罗马历法的具体意见,比如,你是否相信古罗马在公元4年失闰,你同意后人的哪种考据结果,等等。
下面是JDK 1.4文档中的相关解释:
However, dates obtained using GregorianCalendar are historically accurate only from March 1, 4 AD onward, when modern Julian calendar rules were adopted. Before this date, leap year rules were applied irregularly, and before 45 BC the Julian calendar did not even exist.
下面是学术界对公元前45年至公元4年,闰年设置混乱问题的不同意见:
The historic sequence of leap years (i.e. years with a leap day) in this period is not given explicitly by any ancient source, although the existence of the triennial cycle is confirmed by an inscription that dates from 9 or 8 BC. The chronologist Joseph Scaliger established in 1583 that the Augustan reform was instituted in 8 BC, and inferred that the sequence of leap years was 42 BC, 39 BC, 36 BC, 33 BC, 30 BC, 27 BC, 24 BC, 21 BC, 18 BC, 15 BC, 12 BC, 9 BC, AD 8, AD 12 etc. This proposal is still the most widely accepted solution. Other solutions have been proposed from time to time. Kepler proposed in 1614 that the correct sequence of leap years was 43 BC, 40 BC, 37 BC, 34 BC, 31 BC, 28 BC, 25 BC, 22 BC, 19 BC, 16 BC, 13 BC, 10 BC, AD 8, AD 12 etc. In 1883 the German chronologist Matzat proposed 44 BC, 41 BC, 38 BC, 35 BC, 32 BC, 29 BC, 26 BC, 23 BC, 20 BC, 17 BC, 14 BC, 11 BC, AD 4, AD 8, AD 12 etc., based on a passage in Dio Cassius that mentions a leap day in 41 BC that was said to be contrary to Caesar's rule. It has also sometimes been suggested that 45 BC was a leap year. In the 1960s Radke argued the reform was actually instituted when Augustus became pontifex maximus in 12 BC, suggesting the sequence 45 BC, 42 BC, 39 BC, 36 BC, 33 BC, 30 BC, 27 BC, 24 BC, 21 BC, 18 BC, 15 BC, 12 BC, AD 4, AD 8, AD 12 etc.
In 1999, an Egyptian papyrus was published which gives an ephemeris table for 24 BC with both Roman and Egyptian dates. From this it can be shown that the most likely sequence was in fact 44 BC, 41 BC, 38 BC, 35 BC, 32 BC, 29 BC, 26 BC, 23 BC, 20 BC, 17 BC, 14 BC, 11 BC, 8 BC, AD 4, AD 8, AD12 etc., very close to that proposed by Matzat.