Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Jake Lee
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to convert SAP dates to Juilian Dates...anyone can help on this???
Thanks a lot.
Jake
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2545
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic