Here you can find the source of julianDay(int YY, int MM, int DD)
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.
Parameter | Description |
---|---|
YY | Gregorian year |
MM | Gregorian month |
DD | Gregorian day |
public static int julianDay(int YY, int MM, int DD)
//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; } }