• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Julian to Gregorian date conversion

 
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello friends,

I need to do a date conversion from Julian to Gregorian. I searched into javaranch and I got a link where they suggested Joda.

Should i continue with this API or we have other good options?
Thanks.
 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I same to remember reading that GregorianCalendar handles Julian dates before the switch over?

Also its worth noting that not all countries changed to the gregorian claendar at the same time, I beleive (god this is dredge my uni memory) that Great Britain was rather late in changing over compared to teh rest of Europe.
 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Gavin Tranter:
I same to remember reading that GregorianCalendar handles Julian dates before the switch over?


Couldn't catch your words?
Did you mean Gregorian Calender itself manages Julian dates also?


Originally posted by Gavin Tranter:
Also its worth noting that not all countries changed to the gregorian claendar at the same time, I beleive (god this is dredge my uni memory) that Great Britain was rather late in changing over compared to teh rest of Europe.


Thanks for this information.
 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I didn't get good response ranchers. Why?

Anyways after lot googling got one solution.
(courtesy: Get a julian date)


[ April 29, 2008: Message edited by: Vishal Pandya ]
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[Vishal]: Did you mean Gregorian Calender itself manages Julian dates also?

Yes. This is described in the GregorianCalendar API. If you want to create a calendar which is always Julian, callsetGregorianChange() and set it to some date in the far future. Or if you want to create a calendar that is always Gregorian, set the change date to something in the distant past.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Problem: I am working on a multi-tiered system that has components that run on different operating systems. I need a julian timestamp in java that will matchup with the julian timestamp on the Tandem (HP) os. If it were HPUX, that would be great, but it's not.

The beginning of the epoch for Tandem/HP is 12/31/74
The beginning of the epoch for Java is 1/1/70

Right now, the timestamps we're generating are being interpreted as dates in the far future. It's all wrong.
On the PCs and Unix machines, we're fine. On the Tandem, we're in "tomorrowland"...

Any ideas on how I can set the calendar object to have a different "epoch" start date and get a julian timestamp?

Thanks,
Maffy
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you call that "Julian"? There are three kinds of "Julian" dating that I know of:

1. The system used by astronomers to standardly number their days. Its origin is around 3000 BCE (can't remember exactly).

2. The predecessor to the Gregorian calendar which we all use today, which is now only used to find out when religious holidays take place in Eastern European countries.

3. The term "Julian day" to refer to the number of the day in the year, between 1 and 366.

Your Tandem dating doesn't have anything to do with any of those. Hopefully Tandem doesn't use the term "Julian" in their documentation...

Anyway, when you get the number of milliseconds since the Tandem epoch, just add the number of milliseconds between the Java epoch and the Tandem epoch and you'll have the number of milliseconds since the Java epoch. You can calculate that offset in advance.
 
Mary Ann Finnerty
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good timing. What I did was get a calendar object for today, and a calendar object initialized to the tandem epoch start date.
I forced the time values in the tandem calendar to 0 (otherwise it was getting the current hr/min/sec/milli) and used the getTimeInMillis() method for each calendar and did:

today in millis - tandem today in millis / 10 (for centiseconds, since tandem timestamps use centiseconds)


I have a telnet to the tandem where I'm getting the timestamp via command line and a java utility that I just wrote to spit out the timestamps generated here, and they finally match.

Thanks, though, for responding so quickly!

Maffy
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
line 48 in fromJulian should be:
ja = (int) julian;
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic