public final class GregorianMath extends Object
Contains some calendrical tools for the rules of gregorian calendar.
| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_YEAR
Maximum of supported year range (999999999).
|
static int |
MIN_YEAR
Minimum of supported year range (-999999999).
|
| Modifier and Type | Method and Description |
|---|---|
static void |
checkDate(int year,
int month,
int dayOfMonth)
Checks the range limits of date values according to the rules
of gregorian calendar.
|
static int |
getDayOfWeek(int year,
int month,
int dayOfMonth)
Returns the day of week for given gregorian date.
|
static int |
getLengthOfMonth(int year,
int month)
Determines the maximum length of month in days dependent on given
year (leap years!)
|
static boolean |
isLeapYear(int year)
Queries if given year is a gregorian leap year.
|
static boolean |
isValid(int year,
int month,
int dayOfMonth)
Queries if given values form a well defined gregorian date.
|
static int |
readDayOfMonth(long packedDate)
Returns the day of month from given binary compressed date.
|
static int |
readMonth(long packedDate)
Returns the month from given binary compressed date.
|
static int |
readYear(long packedDate)
Returns the year from given binary compressed date.
|
static long |
toMJD(GregorianDate date)
Calculates the modified julian date.
|
static long |
toMJD(int year,
int month,
int dayOfMonth)
Calculates the modified julian date.
|
static long |
toPackedDate(long mjd)
Calculates the gregorian Date based on given modified julian date
in binary compressed format.
|
public static final int MIN_YEAR
public static final int MAX_YEAR
public static boolean isLeapYear(int year)
Queries if given year is a gregorian leap year.
year - number of proleptic yeartrue if it is a leap year else falsepublic static int getLengthOfMonth(int year,
int month)
Determines the maximum length of month in days dependent on given year (leap years!) and month.
year - proleptic iso yearmonth - gregorian month (1-12)IllegalArgumentException - if month is out of range (1-12)public static boolean isValid(int year,
int month,
int dayOfMonth)
Queries if given values form a well defined gregorian date.
This method only checks the range limits, not if the date is historically correct.
year - proleptic iso year [(-999999999) - 999999999]month - gregorian month (1-12)dayOfMonth - day of month (1-31)true if valid else falsecheckDate(int, int, int)public static void checkDate(int year,
int month,
int dayOfMonth)
Checks the range limits of date values according to the rules of gregorian calendar.
year - proleptic iso year [(-999999999) - 999999999]month - gregorian month (1-12)dayOfMonth - day of month (1-31)IllegalArgumentException - if any argument is out of rangeisValid(int, int, int)public static int getDayOfWeek(int year,
int month,
int dayOfMonth)
Returns the day of week for given gregorian date.
This method is based on ISO-8601 and assumes that Monday is the first day of week.
year - proleptic iso yearmonth - gregorian month (1-12)dayOfMonth - day of month (1-31)IllegalArgumentException - if the month or the day are
out of rangepublic static int readYear(long packedDate)
Returns the year from given binary compressed date.
packedDate - packed date in binary formattoPackedDate(long)public static int readMonth(long packedDate)
Returns the month from given binary compressed date.
packedDate - packed date in binary formattoPackedDate(long)public static int readDayOfMonth(long packedDate)
Returns the day of month from given binary compressed date.
packedDate - packed date in binary formattoPackedDate(long)public static long toPackedDate(long mjd)
Calculates the gregorian Date based on given modified julian date in binary compressed format.
Applications can extract the single date components from the result
of this method by mean of readYear(), readMonth() and
readDayOfMonth().
mjd - days since [1858-11-17] (modified julian date)IllegalArgumentException - if the calculated year is not in
range [(-999999999)-999999999)]readYear(long),
readMonth(long),
readDayOfMonth(long)public static long toMJD(GregorianDate date)
Calculates the modified julian date.
date - gregorian dateIllegalArgumentException - if the argument is out of rangetoMJD(int, int, int)public static long toMJD(int year,
int month,
int dayOfMonth)
Calculates the modified julian date.
year - proleptic iso year [(-999999999) - 999999999]month - gregorian month (1-12)dayOfMonth - day of month in range (1-31)IllegalArgumentException - if any argument is out of rangeCopyright © 2014–2015. All rights reserved.