aspose file tools*
The moose likes Beginning Java and the fly likes Julian to Gregorian date conversion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Julian to Gregorian date conversion" Watch "Julian to Gregorian date conversion" New topic
Author

Julian to Gregorian date conversion

Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
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.
Gavin Tranter
Ranch Hand

Joined: Jan 01, 2007
Posts: 333
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

Joined: Aug 16, 2007
Posts: 1374
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

Joined: Aug 16, 2007
Posts: 1374
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 ]
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
[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.


"I'm not back." - Bill Harding, Twister
Mary Ann Finnerty
Greenhorn

Joined: Feb 23, 2004
Posts: 2
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
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

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

Joined: Feb 23, 2004
Posts: 2
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
zur boka
Greenhorn

Joined: Jul 13, 2013
Posts: 1
Hi,
line 48 in fromJulian should be:
ja = (int) julian;
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Julian to Gregorian date conversion