FileDocCategorySizeDatePackage
JulianDate.javaAPI DocExample1336Sat Nov 25 12:54:52 GMT 2000None

JulianDate

public class JulianDate extends GregorianCalendar
Extend GregorianCalendar to provide Julian date. An example of a class that adds methods, but no data
author
Ian Darwin, ian@darwinsys.com
version
$Revision: 1.2 $, $Date: 2000/11/25 17:54:52 $

Fields Summary
public static final int[]
dom
Constructors Summary
JulianDate()

		super();
	
JulianDate(int yy, int mm, int dd)

		super(yy,mm,dd);
	
Methods Summary
private voiddump()

		System.out.println("Date is " + getTime());
		System.out.println("The year " + (isLeapYear(get(YEAR))?"is":"is not") +
			" a leap year");
		System.out.println("The day of year is " + getDayOfYear());
	
public intgetDayOfYear()
getDayOfYear returns the Julian "DayOfYear": Jan 1 = 0, December 31 = 365 or 366.


	               	 
	   
		int t = 0;

		/* Add up months so far, not including current month. */
		for (int i = 0; i<get(MONTH); i++)
			t += dom[i];

		if (isLeapYear(get(YEAR)) && get(MONTH) > 1)
			t++;

		t += get(DAY_OF_MONTH);	// Days so far this month.

		return t;
	
public static voidmain(java.lang.String[] args)

		new JulianDate().dump();
		new JulianDate(1951, 04-1, 24).dump();
		new JulianDate(2000, 00, 01).dump();