A quick look at Calendar and GregorianCalendar shows that there is a "era" parameter which indicates AD or BC. Have you tried changing that that? (Sorry but I haven't had the need to try it myself )
I just found this page, maybe it interests you and gives you a clue on how to do it. [ May 15, 2004: Message edited by: Barry Gaunt ]
Note that the problem with your original code was that it used roll() rather than add(). Consult the API to see the difference. This gives results as you'd expect:
I had to add the SimpleDateFormat because (on my sustem at least) the default date formatter did not bother to specify the era. I.e. it gave the year as 997, rather than 997 BC.
Thank you Jim, Everything is fine except year 0000(BC and AD). I can't make Calendar to 'show' the birthday of Christ!?!? Any comments on this code ,
and the output of it ? IV 16 19:43:35 0001 AD III 16 19:43:35 0001 AD II 16 19:43:35 0001 AD I 16 19:43:35 0001 AD XII 16 19:43:35 0001 BC XI 16 19:43:35 0001 BC X 16 19:43:35 0001 BC IX 16 19:43:35 0001 BC VIII 16 19:43:35 0001 BC VII 16 19:43:35 0001 BC VI 16 19:43:35 0001 BC V 16 19:43:35 0001 BC
The results look correct (assuming you're living somewhere that roman numerals are used to identify the month; that's a new one for me). When using AD and BC, there is no year zero. The Romans had no concept of zero, so they skipped it. If we retrofit zero and negative numbers onto year value, we have:
1001 BC = -1000 1000 BC = -999 2 BC = -1 1 BC = 0 1 AD = +1 1000 AD = +1000
--------------------
"And another thing. If this is the year 6 million and 3, why is next year 6 million and 2? Why are we counting backwards? I mean, what are we waiting for?" -- Robbie Sinclair
Story like this gets better after being told a few times. Or maybe it's just a tiny ad:
New web page for Paul's Rocket Mass Heaters movies