aspose file tools*
The moose likes Java in General and the fly likes [help] any code to convert YYYYMMDD to Julian Date? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "[help] any code to convert YYYYMMDD to Julian Date?" Watch "[help] any code to convert YYYYMMDD to Julian Date?" New topic
Author

[help] any code to convert YYYYMMDD to Julian Date?

Jake Lee
Greenhorn

Joined: Apr 02, 2002
Posts: 18
I am trying to convert SAP dates to Juilian Dates...anyone can help on this???
Thanks a lot.
Jake
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

There might be an easier way using the Calendar class and Calendar.DAY_OF_YEAR, but here is a class already written for you:
org.planetizer.util.JulianDate
hope it helps,
Jamie
John Lee
Ranch Hand

Joined: Aug 05, 2001
Posts: 2545
You may have to do it the hard way.
Sum up all the days in the previous monthes and all the previous days in this month. Take into consideration of leap month.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
If by "Julian date" you mean a date on the Julian calendar, then the GregorianCalendar API tells you how, under the method setGregorianChange(Date):
To obtain a pure Julian calendar, set the change date to Date(Long.MAX_VALUE). To obtain a pure Gregorian calendar, set the change date to Date(Long.MIN_VALUE).

Now I have no idea why anyone would want to use the Julian calendar nowadays, but that is the correct meaning of "Julian date" - a date on the Julian calendar. However some people use the term as lazy (and incorrect) shorthand for "Julian day number", which is the number of days elapsed since noon on 1 January 4713 B.C. (GMT). (Useful for astronomy.) In that case, the link Jamie Robertson gave should be all you need. Or you can perform the calcs yourself by creating a Date for Greenwich mean noon on 1 January 4713 BC, and then compare the getTime() value (in milliseconds) with any other Date you may encounter. You may even use Thomas Paul's new TimeSpan class if you like, once he finishes debugging it.
[ January 29, 2003: Message edited by: Jim Yingst ]

"I'm not back." - Bill Harding, Twister
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [help] any code to convert YYYYMMDD to Julian Date?