• 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

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

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to convert SAP dates to Juilian Dates...anyone can help on this???
Thanks a lot.
Jake
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Always! Wait. Never. Shut up. Look at this tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic