Practical Astronomy : Menghitung Julian Day

Berikut adalah seri postingan tentang astronomi praktis. Seri ini memiliki tujuan akhir yaitu membuat class Java yang berisi perhitungan-perhitungan dari buku Practical Astronomy with your calculator or spreadsheet 4th Edition by Peter Duffett and Jonathan Zwart.

Kali ini menghitung Julian Day dari kalender gregorian day.

public class ShowJulianDay
{
// arguments are passed using the text field below this editor
public static void main(String[] args)
{
PracticalAstronomy astro = new PracticalAstronomy(2009,6,19,18,0,0);
System.out.print(astro.getJulianDay());
}
}
public class PracticalAstronomy
{
private int year;
private int month;
private int day;
private int hour;
private int minute;
private int second;
public PracticalAstronomy(int year,int month,int day,int hour,int minute,int second)
{
this.year = year;
this.month = month;
this.day = day;
this.hour = hour;
this.minute = minute;
this.second = second;
}
public double getJulianDay()
{
boolean julian = true;
if (year < 1582 || (year == 1582 && month <= 10) || (year == 1582 && month == 10 && day < 15)) julian = false;
int D = day;
int M = month;
int Y = year;
if (M < 3)
{
Y--;
M += 12;
}
int A = Y / 100;
int B = julian ? 2 - A + A / 4 : 0;
int C = Y < 0 ? (int)((365.25 * Y) - 0.75) : (int)(365.25 * Y);
int F = (int)(30.6001 * (M + 1));
double dayFraction = (hour + (minute + (second / 60.0)) / 60.0) / 24.0;
double jd = B + C + F + D + dayFraction + 1720994.5;
return jd;
}
}

Untuk testing code diatas bisa menggunakan java compiler dan executor disini https://www.compilejava.net/

One thought on “Practical Astronomy : Menghitung Julian Day”

Leave a Reply to Ardian Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.