• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Calendar and dates BC

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to make calendar that shows date period 01/01/3000 BC - 01/01/3000 AD. But unfortunately
returns 1.
On the other hand

prints Fri May 15 15:18:21 EEST 292277998.
How could I take Calendar instance for the period when Egyptians built the pyramids ?
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Todor Mollov
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your reply !

May be I discovered the warm water again but I found how it works.

prints :
Tue May 16 01:08:23 EET 2004
BC!!!
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Todor Mollov
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic