Convert regular date and time to Julian date and vice versa

Posted by zbz.lvlv on Stack Overflow See other posts from Stack Overflow or by zbz.lvlv
Published on 2014-05-30T03:11:40Z Indexed on 2014/05/30 3:25 UTC
Read the original article Hit count: 435

Filed under:
|
|

I am currently working on a program that will calculate sunrise and sunset times. How do I convert yyyymmddhhmmss to Julian date? I need the date to be very precise. It'll great if there can be an example for such conversions.

        Calendar cNow = Calendar.getInstance();
        Calendar cJan1 = Calendar.getInstance();

        double julianJan1_2014_12_00_00 = 2456659;
        cJan1.set(2014, 0, 0, 12, 0);
        Date dJan1 = cJan1.getTime();
        Date dNow = cNow.getTime();
        long lJan1 = dJan1.getTime();
        long lNow = dNow.getTime();
        double diffDay = (lNow - lJan1) / 1000 / 60 / 60 / 24;
        double julianDate = diffDay + julianJan1_2014_12_00_00;

The code I currently have.

© Stack Overflow or respective owner

Related posts about java

Related posts about date