Java Julian Date julianDay(int YY, int MM, int DD)

Here you can find the source of julianDay(int YY, int MM, int DD)

Description

calculation of julianDay based on http://www.imcce.fr/en/grandpublic/temps/jour_julien.php This is slightly slower because of a cusp at 1582, but is accurate before these times.

License

Open Source License

Parameter

Parameter Description
YY Gregorian year
MM Gregorian month
DD Gregorian day

Return

the Julian day.

Declaration

public static int julianDay(int YY, int MM, int DD) 

Method Source Code

//package com.java2s;
/*// w w  w.j  av a2 s .co m
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

public class Main {
    /**
     * calculation of julianDay based on 
     * http://www.imcce.fr/en/grandpublic/temps/jour_julien.php
     * This is slightly slower because of a cusp at 1582, but is accurate
     * before these times.
     * @param YY  Gregorian year
     * @param MM  Gregorian month
     * @param DD Gregorian day
     * @return the Julian day.
     */
    public static int julianDay(int YY, int MM, int DD) {
        int GGG = 1;
        if (YY < 1582)
            GGG = 0;
        if (YY <= 1582 && MM < 10)
            GGG = 0;
        if (YY <= 1582 && MM == 10 && DD < 5)
            GGG = 0;
        int JD = -1 * (7 * (((MM + 9) / 12) + YY) / 4);
        int S = 1;
        if ((MM - 9) < 0)
            S = -1;
        int A = Math.abs(MM - 9);
        int J1 = (YY + S * (A / 7));
        J1 = -1 * (((J1 / 100) + 1) * 3 / 4);
        JD = JD + (275 * MM / 9) + DD + (GGG * J1);
        JD = JD + 1721027 + 2 * GGG + 367 * YY;
        return JD;
    }
}

Related

  1. julian(int date)
  2. julianCentury(double JD)
  3. julianCentury(double julianDay)
  4. julianDate2JDN(int year, int month, int day)
  5. julianDay(int day, int month, int year)
  6. JulianDaysToUnix(double jd)
  7. julianToString(StringBuilder buf, int julian)