public class Day extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private int |
date |
private static int[] |
DAYS_PER_MONTH |
private static int |
DECEMBER |
private static int |
FEBRUARY |
private static int |
GREGORIAN_START_DAY |
private static int |
GREGORIAN_START_MONTH |
private static int |
GREGORIAN_START_YEAR |
private static int |
JANUARY |
private static int |
JULIAN_END_DAY |
private int |
month |
private int |
year |
Constructor and Description |
---|
Day(int aYear,
int aMonth,
int aDate)
Constructs a day with a given year, month, and day
of the Julian/Gregorian calendar.
|
Modifier and Type | Method and Description |
---|---|
Day |
addDays(int n)
Returns a day that is a certain number of days away from
this day
|
private int |
compareTo(Day other)
Compares this day with another day.
|
int |
daysFrom(Day other)
Returns the number of days between this day and another
day
|
private static int |
daysPerMonth(int y,
int m)
Gets the days in a given month
|
int |
getDate()
Returns the day of the month of this day
|
int |
getMonth()
Returns the month of this day
|
int |
getYear()
Returns the year of this day
|
private static boolean |
isLeapYear(int y)
Tests if a year is a leap year
|
private Day |
nextDay()
Computes the next day.
|
private Day |
previousDay()
Computes the previous day.
|
private int year
private int month
private int date
private static final int[] DAYS_PER_MONTH
private static final int GREGORIAN_START_YEAR
private static final int GREGORIAN_START_MONTH
private static final int GREGORIAN_START_DAY
private static final int JULIAN_END_DAY
private static final int JANUARY
private static final int FEBRUARY
private static final int DECEMBER
public Day(int aYear, int aMonth, int aDate)
aYear
- a year != 0aMonth
- a month between 1 and 12aDate
- a date between 1 and 31public int getYear()
public int getMonth()
public int getDate()
public Day addDays(int n)
n
- the number of days, can be negativepublic int daysFrom(Day other)
other
- the other dayprivate int compareTo(Day other)
other
- the other dayprivate Day previousDay()
private static int daysPerMonth(int y, int m)
y
- the yearm
- the monthprivate static boolean isLeapYear(int y)
y
- the year