Java Julian Date julianDay(int day, int month, int year)

Here you can find the source of julianDay(int day, int month, int year)

Description

julian Day

License

Apache License

Declaration

private static double julianDay(int day, int month, int year) 

Method Source Code

//package com.java2s;
/*/*from  www  .j  av  a 2s. c  o  m*/
 * Copyright 2010 Roger Kapsi
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */

public class Main {
    private static final int GRGORIAN_BEGIN_YEAR = 1582;
    private static final int GRGORIAN_BEGIN_MONTH = 10;
    private static final int GRGORIAN_BEGIN_DAY = 15;

    private static double julianDay(int day, int month, int year) {
        int a = 0;
        int b = 0;

        boolean isGregorian = false;
        if (year > GRGORIAN_BEGIN_YEAR) {
            isGregorian = true;
        } else if (year == GRGORIAN_BEGIN_YEAR) {
            if (month > GRGORIAN_BEGIN_MONTH) {
                isGregorian = true;
            } else if (month == GRGORIAN_BEGIN_MONTH) {
                if (day >= GRGORIAN_BEGIN_DAY) {
                    isGregorian = true;
                }
            }
        }

        if (month < 3) {
            year--;
            month += 3;
        }

        if (isGregorian) {
            a = year / 100;
            b = 2 - a + (int) (a / 4);
        }

        return ((int) 365.25 * (year + 4716)) + (int) (30.6001 * (month + 1)) + day + (double) b - 1524.5;
    }
}

Related

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