com.mindprod.common11
Class BigDate

java.lang.Object
  extended by com.mindprod.common11.BigDate
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable

public final class BigDate
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable, java.lang.Comparable

Manipulate pure dates, without time or time zone.

Convert Gregorian YYYY MM DD back and forth to ordinal days since 1970-01-01, Thursday (sometimes called Julian or datestamp form). BigDate objects are not designed for storing dates in a database, just for conversion. Long term storage should store the ordinal either as an int, or possibly as a short. The BigDate constructor stores the date both in ordinal and Gregorian forms internally. If you store one, it creates the other.

The standard Sun Date won't handle dates prior to 1970 among other problems. BigDate handles dates 999,999 BC Jan 1 to 999,999 AD Dec 31, 0 = 1970-01-01.

Are the following quirks of the calendar considered in this code?

1900 is not a leap year (mod 100): yes.

2000 is a leap year (mod 400): yes.

The 10 missing days in 1582 October.: yes (Pope Gregory's correction) 1582-10-05 to 1582-10-14 never happened.

Britain and its territories (including the USA and Canada) adopted the Gregorian correction in 1752: Yes. By then, 11 days had to be dropped. 1752-09-03 to 1752-09-13 never happened. However, you can modify constants in BigDate to use the British calendar. Such a change only affects dates prior to 1753 since BigDate calendar is based on 1970-01-01. toOrdinal with the Gregorian and British scheme will give the same number for recent dates. You must recompile BigDate with the isBritish boolean changed to true.. It was used by Britain and its colonies which later became the USA and Canada. However Nova Scotia used Pope Gregory's calendar. see http://mindprod.com/jgloss/missingdays.html PLEASE CONFIGURE isBritish AND RECOMPILE BigDate IF YOU WISH TO USE THE BRITISH CALENDAR.

missing year 0 between 1 BC and 1 AD. yes.

in Roman times leap years occurred at irregular intervals, Considered inauspicious, they were avoided during war. no. Instead we presume leap years every 4 years even back to 999,999BC.

leap seconds: no

Normally all you need is one BigDate object that you use for all interconversions with set(ordinal), set(yyy,mm,dd) and getOrdinal(), getYYYY(), getMM(), getDD().

java.util.Date has some odd habits, using 101 to represent the year 2001, and 11 to represent December. BigDate is more conventional. You use 2001 to represent the year 2001 and 12 to represent December.

BigDate implements proleptic Gregorian and Julian calendars. That is, dates are computed by extrapolating the current rules indefinitely far backward and forward in time. As a result, BigDate may be used for all years to generate meaningful and consistent results. However, dates obtained using BigDate are historically accurate only from March 1, 4 AD onward, when modern Julian calendar rules were adopted. Before this date, leap year rules were applied irregularly, and before 45 BC the Julian calendar did not even exist. Prior to the institution of the Gregorian calendar, New Year's Day was March 25. To avoid confusion, this calendar always uses January 1.

TODO Future enhancements: - handle time, and time zones, interconversion with GregorianCalendar dates.

Since:
1997-05-03
Version:
5.7 2011-02-09 add toOrdinal ( yyyy_mm_dd ), throw NumberFormatException instead of IllegalArgumentException.
Author:
Roedy Green, Canadian Mind Products
See Also:
Serialized Form

Field Summary
static int APR
          April is 4
static int APRIL
          April is 4
static int AUG
          August is 8
static int AUGUST
          August is 8
static int BYPASSCHECK
          Constant: when passed to a constructor, it means caller guarantees YYYY MM DD are valid including leap year effects and missing day effects.
static int CHECK
          constant: when passed to a contructor it means BigDate should check that YYYY MM DD are valid.
protected  int dd
          Day, 1 to 31.
static int DEC
          December is 12
static int DECEMBER
          December is 12
static int FEB
          February is 2
static int FEBRUARY
          February is
static int FRI
          Friday in BigDate is 5
static int FRIDAY
          Friday in BigDate is 5
static boolean isBritish
          PLEASE CONFIGURE isBritish BEFORE COMPILING.
static int JAN
          January is 1
static int JANUARY
          January is 1
static int JUL
          July is 7
static int JULY
          July is 7
static int JUN
          June is 6
static int JUNE
          June is 6
static int MAR
          March is 3
static int MARCH
          March is 3
static int MAX_ORDINAL
          Constant: biggest ordinal that BigDate will accept, corresponds to 999,999 Dec 31 AD.
static int MAX_YEAR
          Constant: biggest year that BigDate handles, 999,999 AD.
static int MAY
          May is 5
static int MIN_ORDINAL
          Constant: earliest ordinal that BigDate handles; corresponds to 999,999 Jan 01 BC.
static int MIN_YEAR
          Constant: earliest year that BigDate handles, 999,999 BC.
protected  int mm
          Month, 1 to 12.
static int MON
          Monday in BigDate is 1
static int MONDAY
          Monday in BigDate is 1
static int NORMALISE
          Constant: when passed to a constructor, it means any invalid dates are converted into the equivalent valid ones.
static int NORMALIZE
          Constant: American spelling alias for NORMALISE.
static int NOV
          November is 11
static int NOVEMBER
          November is 11
static int NULL_ORDINAL
          Constant: ordinal to represent a null date -2,147,483,648, null Gregorian is 0,0,0.
static long NULL_TIMESTAMP
          Constant : value for a null TimeStamp -9,223,372,036,854,775,808
static int OCT
          October is 10
static int OCTOBER
          October is 10
protected  int ordinal
          Ordinal days since Jan 01, 1970.
static int SAT
          Saturday in BigDate is 6
static int SATURDAY
          Saturday in BigDate is 6
static int SEP
          September is 9
static int SEPTEMBER
          September is 9
(package private) static long serialVersionUID
          used to identify this version of serialised BigDate objects
static int SUN
          Sunday is 0
static int SUNDAY
          Sunday is 0
static int THU
          Thursday in BigDate is 4
static int THURSDAY
          Thursday in BigDate is 4
static int TUE
          Tuesday in BigDate is 2
static int TUESDAY
          Tuesday in BigDate is 2
static int WED
          Wednesday in BigDate is 3
static int WEDNESDAY
          Wednesday in BigDate is 3
protected  int yyyy
          Year, -999,999 to +999,999, negative is BC, positive is AD, 0 is null.
 
Constructor Summary
BigDate()
          Constructor for the null date.
BigDate(BigDate b)
          Copy constructor
BigDate(java.util.Date utc, java.util.TimeZone timeZone)
          Constructor from Date, loses time information.
BigDate(double prolepticJulianDay)
          Construct a BigDate object given the Proleptic Julian day number.
BigDate(int ordinal)
          Ordinal constructor.
BigDate(int yyyy, int mm, int dd)
          Construct a BigDate object given a Gregorian date yyyy, mm, dd; always rejects invalid dates.
BigDate(int yyyy, int mm, int dd, int how)
          Construct a BigDate object given a Gregorian date yyyy, mm, dd; allows control of how invalid dates are handled.
BigDate(java.lang.String yyyy_mm_dd)
          Create a BigDate object from a String of the form: yyyy-mm-dd must have 4-digit years, and use dashes between the number and no sign Does extensive checks considering leap years, missing days etc.
 
Method Summary
 void addDays(int days)
          increment this date by a number of days.
static int[] age(BigDate birthDate, BigDate asOf)
          calculate the age in years, months and days.
protected  void calcOrdinal()
          Convert date in form YYYY MM DD into days since the epoch, leaving results internally.
 int calendarDayOfWeek()
          Get day of week for this BigDate.
static int calendarDayOfWeek(int ordinal)
          Get day of week for given ordinal.
 java.lang.Object clone()
          standard clone.
static int compare(int yyyy1, int mm1, int dd1, int yyyy2, int mm2, int dd2)
          Compare two dates in yyyy mm dd form.
 int compareTo(java.lang.Object other)
          Compare BigDates in ascending date order.
static java.lang.String dayAbbr(int dayOfWeek)
          Get 3-char abbreviation of a given day of the week
static java.lang.String dayName(int dayOfWeek)
          Get full name of given day of the week
 int dayOfWeek()
          Get day of week for this BigDate.
static int dayOfWeek(int ordinal)
          Get day of week for given ordinal.
static int daysInMonth(int mm, boolean leap)
          How many days are there in a given month?
static int daysInMonth(int mm, int yyyy)
          How many days are there in a given month?
protected static int daysInYearPriorToMonth(int mm, boolean leap)
          How many days were there in the year prior to the first day of the given month?
protected static int dddToMM(int ddd, boolean leap)
          Convert day number ddd in year to month.
 boolean equals(java.lang.Object d)
          Compares with another BigDate to see if they refer to the same date.
static int flooredMulDiv(int multiplicand, int multiplier, int divisor)
          Multiply then divide using floored rather than the usual truncated arithmetic, using a long intermediate.
 int getCalendarDayOfWeek()
          Get day of week for this BigDate.
static java.lang.String getCopyright()
          Embeds copyright notice
 java.util.Date getDate(java.util.TimeZone timeZone)
          Get java.util.Date object corresponding to this BigDate,
 int getDayOfWeek()
          Get day of week for this BigDate.
 int getDD()
          get day of month for this BigDate.
 int getDDD()
          Get day number in the year for this BigDate.
 int getISODayOfWeek()
          Get day of week 1 to 7 for this BigDate according to the ISO standard IS-8601.
 int getISOWeekNumber()
          Get week number 1 to 53 of the year this date falls in, according to the rules of ISO standard IS-8601.
 java.util.Date getLocalDate()
          Get java.util.Date object corresponding to this BigDate.
 long getLocalTimeStamp()
          Get milliseconds since 1970-01-01 00:00 GMT for this BigDate.
 int getMM()
          Get month of year for this BigDate.
 int getOrdinal()
          get days since 1970-01-01 for this BigDate.
 double getProlepticJulianDay()
           
 int getSeason()
          Get season of year for this BigDate.
 long getTimeStamp(java.util.TimeZone timeZone)
          Get milliseconds since 1970-01-01 00:00 GMT for this BigDate, as at the start of day 0:00.
 java.util.Date getUTCDate()
          Get java.util.Date object corresponding to this BigDate.
 long getUTCTimeStamp()
          Get milliseconds since 1970-01-01 00:00 GMT for this BigDate.
 int getWeekNumber()
          Get week number 1 to 53 of the year this date falls in.
 int getYYYY()
          Get year for this BigDate.
 int hashCode()
          hashCode for use in Hashtable/HashMap lookup
static boolean isAnniversary(BigDate birthDate, BigDate asOf)
          Determine if this date is someone's birthdate, or the aniversary of their death, or the anniversary of a marriage etc.
static boolean isLeap(int yyyy)
          Is the given year a leap year, considering history, mod 100 and mod 400 rules? By 1582, this excess of leap years had built up noticeably.
static int isoDayOfWeek(int ordinal)
          Get day of week 1 to 7 for this ordinal according to the ISO standard IS-8601.
static boolean isValid(int yyyy, int mm, int dd)
          Test to see if the given yyyy, mm, dd date is legitimate.
static boolean isValid(java.lang.String yyyy_mm_dd)
          Test to see if the given yyyy-mm-dd is a date as a String is legitimate.
protected static int jan01OfYear(int yyyy)
          Ordinal date of Jan 01 of the given year.
static BigDate localToday()
          Returns a BigDate object initialised to today's local date.
static java.lang.String monthAbbr(int mm)
          Get 3-char abbreviation of a given month of the year.
static java.lang.String monthName(int mm)
          Get full name of a given month of the year.
 BigDate nearestXXXDay(int dayOfWeek)
          Find the BigDate with date closest to this one with the given day of week.
protected  void normalise()
          Clean up an invalid date, leaving the results internally e.g.
static int nthXXXDay(int which, int dayOfWeek, int yyyy, int mm)
          Find the first monday in a given month, the 3rd monday or the last Thursday...
 int ordinal()
          get days since 1970-01-01 for this BigDate.
static int ordinalOfnthXXXDay(int which, int dayOfWeek, int yyyy, int mm)
          Find the first monday in a given month, the 3rd monday or the last Thursday...
static int parseYYYY(java.lang.String yyyyString)
          parse a string into yyyy which may have form: 1948 230BC 1234AD It does not allow a space before the BC or AD.
static BigDate parseYYYYmmdd(java.lang.String incomplete)
          Parse a, possibly incomplete, date String of form yyyy-yy-dd or yyyy-mm or yyyy into a BigDate Also handles AD/BC, 1-digit months, 1-digit days and 1, 2 or 3-digit years.
 void set(int ordinal)
          Set the ordinal field, and compute the equivalent internal Gregorian yyyy mm dd fields.
 void set(int yyyy, int mm, int dd)
          Set the yyyy mm dd Gregorian fields, and compute the internal ordinal equivalent.
 void set(int yyyy, int mm, int dd, int how)
          Set the Gregorian fields, and compute the ordinal equivalent with the same modifiers CHECK, NORMALIZE, BYPASSCHECK as the constructor.
 void setDateAtTime(long utcTimestamp, java.util.TimeZone timeZone)
          Sets the date that corresponding to a given utc timestamp at a given TimeZone.
 void setOrdinal(int ordinal)
          Set the ordinal field, and compute the equivalent internal Gregorian yyyy mm dd fields.
static BigDate today(java.util.TimeZone timeZone)
          Returns a BigDate object initialised to the date right now in the given TimeZone.
 java.lang.String toDowMMDDYY()
          Convert date to a human-readable String [wed mm/dd/yy]
protected  void toGregorian()
          converts ordinal to YYYY MM DD, leaving results internally.
static int toOrdinal(int yyyy, int mm, int dd)
          Convert date in form YYYY MM DD into days since the 1970-01-01.
static int toOrdinal(java.lang.String yyyy_mm_dd)
          Convert ISO date string in form YYYY-MM-DD into days since the 1970-01-01.
 java.lang.String toString()
          Convert date to a human-readable String.
 java.lang.String toYYYYString()
          Convert just year part of date to a human-readable String.
static BigDate UTCToday()
          Returns a BigDate object initialised to today's UTC (Greenwich GMT) date, in other words the date and time in Greenwich England right now without any summer time correction.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

isBritish

public static final boolean isBritish
PLEASE CONFIGURE isBritish BEFORE COMPILING. Mysterious missing days in the calendar. Pope Gregory: 1582-10-04 Thursday, was followed immediately by 1582-10-15 Friday dropping 10 days. British: 1752-09-02 Wednesday was followed immediately by 1752-09-14 Thursday dropping 12 days. Constant: true if you want the British calender, false if Pope Gregory's. You must recompile for it to have effect. For Britain, the USA and Canada it should be true.

See Also:
Constant Field Values

APR

public static final int APR
April is 4

See Also:
Constant Field Values

APRIL

public static final int APRIL
April is 4

See Also:
Constant Field Values

AUG

public static final int AUG
August is 8

See Also:
Constant Field Values

AUGUST

public static final int AUGUST
August is 8

See Also:
Constant Field Values

BYPASSCHECK

public static final int BYPASSCHECK
Constant: when passed to a constructor, it means caller guarantees YYYY MM DD are valid including leap year effects and missing day effects. BigDate will not bother to check them.

See Also:
CHECK, NORMALIZE, NORMALISE, Constant Field Values

CHECK

public static final int CHECK
constant: when passed to a contructor it means BigDate should check that YYYY MM DD are valid.

See Also:
BYPASSCHECK, NORMALIZE, NORMALISE, Constant Field Values

DEC

public static final int DEC
December is 12

See Also:
Constant Field Values

DECEMBER

public static final int DECEMBER
December is 12

See Also:
Constant Field Values

FEB

public static final int FEB
February is 2

See Also:
Constant Field Values

FEBRUARY

public static final int FEBRUARY
February is

See Also:
Constant Field Values

FRI

public static final int FRI
Friday in BigDate is 5

See Also:
Constant Field Values

FRIDAY

public static final int FRIDAY
Friday in BigDate is 5

See Also:
Constant Field Values

JAN

public static final int JAN
January is 1

See Also:
Constant Field Values

JANUARY

public static final int JANUARY
January is 1

See Also:
Constant Field Values

JUL

public static final int JUL
July is 7

See Also:
Constant Field Values

JULY

public static final int JULY
July is 7

See Also:
Constant Field Values

JUN

public static final int JUN
June is 6

See Also:
Constant Field Values

JUNE

public static final int JUNE
June is 6

See Also:
Constant Field Values

MAR

public static final int MAR
March is 3

See Also:
Constant Field Values

MARCH

public static final int MARCH
March is 3

See Also:
Constant Field Values

MAX_ORDINAL

public static final int MAX_ORDINAL
Constant: biggest ordinal that BigDate will accept, corresponds to 999,999 Dec 31 AD.


MAX_YEAR

public static final int MAX_YEAR
Constant: biggest year that BigDate handles, 999,999 AD.

See Also:
Constant Field Values

MAY

public static final int MAY
May is 5

See Also:
Constant Field Values

MIN_ORDINAL

public static final int MIN_ORDINAL
Constant: earliest ordinal that BigDate handles; corresponds to 999,999 Jan 01 BC.


MIN_YEAR

public static final int MIN_YEAR
Constant: earliest year that BigDate handles, 999,999 BC.

See Also:
Constant Field Values

MON

public static final int MON
Monday in BigDate is 1

See Also:
Constant Field Values

MONDAY

public static final int MONDAY
Monday in BigDate is 1

See Also:
Constant Field Values

NORMALISE

public static final int NORMALISE
Constant: when passed to a constructor, it means any invalid dates are converted into the equivalent valid ones. e.g. 1954-09-31 -> 1954-10-01. 1954-10- minus 1 -> 1954-09-30 1954-13-01 -> 1955-01-01.

See Also:
CHECK, BYPASSCHECK, NORMALIZE, Constant Field Values

NORMALIZE

public static final int NORMALIZE
Constant: American spelling alias for NORMALISE.

See Also:
CHECK, BYPASSCHECK, NORMALISE

NOV

public static final int NOV
November is 11

See Also:
Constant Field Values

NOVEMBER

public static final int NOVEMBER
November is 11

See Also:
Constant Field Values

NULL_ORDINAL

public static final int NULL_ORDINAL
Constant: ordinal to represent a null date -2,147,483,648, null Gregorian is 0,0,0.

See Also:
Constant Field Values

OCT

public static final int OCT
October is 10

See Also:
Constant Field Values

OCTOBER

public static final int OCTOBER
October is 10

See Also:
Constant Field Values

SAT

public static final int SAT
Saturday in BigDate is 6

See Also:
Constant Field Values

SATURDAY

public static final int SATURDAY
Saturday in BigDate is 6

See Also:
Constant Field Values

SEP

public static final int SEP
September is 9

See Also:
Constant Field Values

SEPTEMBER

public static final int SEPTEMBER
September is 9

See Also:
Constant Field Values

SUN

public static final int SUN
Sunday is 0

See Also:
Constant Field Values

SUNDAY

public static final int SUNDAY
Sunday is 0

See Also:
Constant Field Values

THU

public static final int THU
Thursday in BigDate is 4

See Also:
Constant Field Values

THURSDAY

public static final int THURSDAY
Thursday in BigDate is 4

See Also:
Constant Field Values

TUE

public static final int TUE
Tuesday in BigDate is 2

See Also:
Constant Field Values

TUESDAY

public static final int TUESDAY
Tuesday in BigDate is 2

See Also:
Constant Field Values

WED

public static final int WED
Wednesday in BigDate is 3

See Also:
Constant Field Values

WEDNESDAY

public static final int WEDNESDAY
Wednesday in BigDate is 3

See Also:
Constant Field Values

NULL_TIMESTAMP

public static final long NULL_TIMESTAMP
Constant : value for a null TimeStamp -9,223,372,036,854,775,808

See Also:
Constant Field Values

serialVersionUID

static final long serialVersionUID
used to identify this version of serialised BigDate objects

See Also:
Constant Field Values

dd

protected transient int dd
Day, 1 to 31. If size of BigDate objects were a consideration, you could make this a byte.


mm

protected transient int mm
Month, 1 to 12. If size of BigDate objects were a consideration, you could make this a byte.


ordinal

protected int ordinal
Ordinal days since Jan 01, 1970. -365968798 to 364522971. i.e. 999,999 BC to 999,999 AD.


yyyy

protected transient int yyyy
Year, -999,999 to +999,999, negative is BC, positive is AD, 0 is null. If I were rewriting this, I would likely encode year 1 BC as 0, and convert on output. That would simplify calculation over the 1AD -1BC barrrier.

Constructor Detail

BigDate

public BigDate()
Constructor for the null date. Gets set to null date, NOT current date like Java Date!!. BigDate.localToday() will create an object initialised to today's date.

See Also:
localToday(), UTCToday(), today(java.util.TimeZone)

BigDate

public BigDate(double prolepticJulianDay)
Construct a BigDate object given the Proleptic Julian day number. The Proleptic Julian calendar that astronomers use starts with 0 at noon on 4713 BCE January 1. In contrast, BigDate's Ordinal base is 1970-01-01.

Parameters:
prolepticJulianDay - days since 4713 BC Jan 1 noon. Such numbers usually arise in astronomical calculation. You don't need to concern yourself with the strangeness of the Julian calendar, just its simple day numbering. BEWARE! after adjusting for noon, fractional parts are discarded. BigDate tracks only dates, not dates and times. e.g. 2000-03-20 noon is 2,451,624 in proleptic day numbers. 1970-01-01 is 2,440,588 1600-1-1 is 2,305,448 1500-1-1 is 2,268,933 0001-1-1 is 1,721,424 -0001-12-31 is 1,721,423 -0006-1-1 is 1,719,232 -4713-1-1 is 0

BigDate

public BigDate(int ordinal)
Ordinal constructor. The ordinal must be NULL_ORDINAL or in the range -365968798 to 364522971 i.e. 999,999 BC to 999,999 AD

Parameters:
ordinal - days since 1970-01-01.

BigDate

public BigDate(java.lang.String yyyy_mm_dd)
Create a BigDate object from a String of the form: yyyy-mm-dd must have 4-digit years, and use dashes between the number and no sign Does extensive checks considering leap years, missing days etc.

Parameters:
yyyy_mm_dd - string of form "yyyy-mm-dd". yyyy-mm-dd y-mm-ddBC 2009-12-31 1234-5-31AD 1970/3/3 AD 3.01.12 bc 2000_12_31 It will not accept a date missing the year, month or day field. Spaces and commas are ignored.

BigDate

public BigDate(BigDate b)
Copy constructor

Parameters:
b - an existing BigDate object to use as a model for cloning another.

BigDate

public BigDate(java.util.Date utc,
               java.util.TimeZone timeZone)
Constructor from Date, loses time information.

Parameters:
utc - Date ( UTC date/time stamp )
timeZone - Which timeZone do you want to know the date for that UTC time. e.g. TimeZone.getDefault(), new TimeZone("GMT")

BigDate

public BigDate(int yyyy,
               int mm,
               int dd)
Construct a BigDate object given a Gregorian date yyyy, mm, dd; always rejects invalid dates. A null date is yyyy,mm,dd=0. BEWARE! In Java a lead 0 on an integer implies OCTAL.

Parameters:
yyyy - -999,999 (BC) to +999,999 (AD)
mm - month 1 to 12 (not 0 to 11 as in Sun's Date), no lead 0.
dd - day 1 to 31, no lead 0.
Throws:
java.lang.NumberFormatException - for invalid yyyy mm dd

BigDate

public BigDate(int yyyy,
               int mm,
               int dd,
               int how)
Construct a BigDate object given a Gregorian date yyyy, mm, dd; allows control of how invalid dates are handled. A null date is yyyy,mm,dd=0. BEWARE! In Java a lead 0 on an integer implies OCTAL.

Parameters:
yyyy - -999,999 (BC) to +999,999 (AD)
mm - month 1 to 12 (not 0 to 11 as in Sun's Date), no lead 0.
dd - day 1 to 31, no lead 0.
how - one of CHECK BYPASSCHECK NORMALIZE NORMALISE
Method Detail

UTCToday

public static BigDate UTCToday()
Returns a BigDate object initialised to today's UTC (Greenwich GMT) date, in other words the date and time in Greenwich England right now without any summer time correction. It works even if Java's default TimeZone is not configured correctly, but it requires your system clock accurately set to UTC time. Experiment setting your system date/time to various values and making sure you are getting the expected results. Note the date in the created object does not keep updating every time you reference it with methods like getOrdinal or getDD. You always get the date the object was created.

Returns:
BigDate object initialised to today, in Greenwich.
See Also:
localToday(), today(java.util.TimeZone)

age

public static int[] age(BigDate birthDate,
                        BigDate asOf)
calculate the age in years, months and days. To compute elapsed time between two dates, use the first as the birthDate and the second as the asOf. DeathDate for asOf gives age at time of death. Today for asOf gives age today.

Parameters:
birthDate - usually the birth of a person.
asOf - usually today, the day you want the age as of. asOf must come after birthDate to get a meaningful result. Usually asOf > birthDate. Difference is always positive no matter if asOf is > or < birthDate
Returns:
array of three ints (not Integers). [0]=age in years, [1]=age in months, [2]=age in days.
See Also:
localToday(), today(java.util.TimeZone), UTCToday(), isAnniversary(com.mindprod.common11.BigDate, com.mindprod.common11.BigDate)

calendarDayOfWeek

public static int calendarDayOfWeek(int ordinal)
Get day of week for given ordinal. It is one-based starting with Sunday.

Parameters:
ordinal - days since 1970-01-01 to test.
Returns:
day of week 1=Sunday 2=Monday 3=Tuesday 4=Wednesday 5=Thursday 6=Friday 7=Saturday Compatible with Sun's 1=Calendar.SUNDAY Not compatible with BigDate.getDayOfWeek.
See Also:
isoDayOfWeek(int), dayOfWeek(int), getCalendarDayOfWeek()

compare

public static final int compare(int yyyy1,
                                int mm1,
                                int dd1,
                                int yyyy2,
                                int mm2,
                                int dd2)
Compare two dates in yyyy mm dd form.

Parameters:
yyyy1 - first year
mm1 - first month 1..12
dd1 - first day 1..31
yyyy2 - second year
mm2 - second month 1..12
dd2 - second day 1..31
Returns:
+ve if date1 > date2, -ve if date1 < date2 and 0 if date1 == date2
See Also:
compareTo(Object)

dayAbbr

public static java.lang.String dayAbbr(int dayOfWeek)
Get 3-char abbreviation of a given day of the week

Parameters:
dayOfWeek - sunday = 0
Returns:
abbreviation for day of week, e.g. "sun", all lower case.

dayName

public static java.lang.String dayName(int dayOfWeek)
Get full name of given day of the week

Parameters:
dayOfWeek - sunday = 0
Returns:
name of day of week e.g. "Sunday"

clone

public java.lang.Object clone()
standard clone.

Overrides:
clone in class java.lang.Object
Returns:
Because this is JDK 1.1 we return Object, not BigDate. You must cast.

dayOfWeek

public static int dayOfWeek(int ordinal)
Get day of week for given ordinal. Is it zero-based starting with Sunday.

Parameters:
ordinal - days since 1970-01-01 to test.
Returns:
day of week 0=Sunday 1=Monday 2=Tuesday 3=Wednesday 4=Thursday 5=Friday 6=Saturday WARNING: not compatible with 1=Calendar.SUNDAY
See Also:
calendarDayOfWeek(int), isoDayOfWeek(int), getDayOfWeek()

daysInMonth

public static int daysInMonth(int mm,
                              boolean leap)
How many days are there in a given month?

Parameters:
mm - month 1 to 12 (not 0 to 11 as in Sun's Date), no lead 0.
leap - true if you are interested in a leap year
Returns:
how many days are in that month

daysInMonth

public static int daysInMonth(int mm,
                              int yyyy)
How many days are there in a given month?

Parameters:
mm - month 1 to 12 (not 0 to 11 as in Sun's Date), no lead 0, or you will get octal.
yyyy - year of interest.
Returns:
how many days are in that month

flooredMulDiv

public static int flooredMulDiv(int multiplicand,
                                int multiplier,
                                int divisor)
Multiply then divide using floored rather than the usual truncated arithmetic, using a long intermediate.

Parameters:
multiplicand - one of two numbers to multiply together
multiplier - one of two numbers to multiply together
divisor - number to divide by
Returns:
(multiplicand times multiplier) / divisor

getCopyright

public static java.lang.String getCopyright()
Embeds copyright notice

Returns:
copyright notice

isAnniversary

public static boolean isAnniversary(BigDate birthDate,
                                    BigDate asOf)
Determine if this date is someone's birthdate, or the aniversary of their death, or the anniversary of a marriage etc. For example boolean todayIsYourBirthday = BigDate.isAnniversary( born, BigDate.localToday() ); boolean todayIsYourWeddingAnniversary = BigDate.isAnniversary( weddingDate, BigDate.localToday() ); boolean todayAnniversaryDeathOfBach = BigDate.isAnniversary( new BigDate("1750-07-28"), BigDate.localToday());

To compute relative anniversary between two dates, use the first as the birthDate and the second as the asof.

February 29 is treated specially, to handle the way people people born on Feb 29 celebrate their birth days on Feb 28 in non-leap years. If the asOf year is not a leap year then Feb 28 is considered a match for Feb 29. However, if the asOf date is Feb 29 then Feb 28 in the birth year is not considered a match.

Parameters:
birthDate - usually the birth of a person, or possibly a date.
asOf - usually today, the day you want the to know if it is an anniversary. asof must come after birthDate to get a meaningful result.
Returns:
true if asOf date in as even number of years after the birthdate. If the asOf date is <= birthDate it will return false.
See Also:
age(com.mindprod.common11.BigDate, com.mindprod.common11.BigDate)

isLeap

public static boolean isLeap(int yyyy)
Is the given year a leap year, considering history, mod 100 and mod 400 rules? By 1582, this excess of leap years had built up noticeably. At the suggestion of astronomers Luigi Lilio and Christopher Clavius, Pope Gregory XIII dropped 10 days from the calendar. Thursday 1582 October 4 Julian was followed immediately by Friday 1582 October 15 Gregorian. He decreed that every 100 years, a leap year should be dropped except that every 400 years the leap year should be restored. Only Italy, Poland, Portugual and Spain went along with the new calendar immediately. One by one other countries adopted it in different years. Britain and its territories (including the USA and Canada) adopted it in 1752. By then, 11 days had to be dropped. 1752-09-02 was followed immediately by 1752-09-14. The Gregorian calendar is the most widely used scheme. This is the scheme endorsed by the US Naval observatory. It corrects the year to 365.2425. It gets ahead 1 day every 3289 years. For BC dates, the years the years 1, 5, 9 are leap years, not 4, 8, 12 as you might expect, from the general rule.

Parameters:
yyyy - year to test.
Returns:
true if the year is a leap year.

isValid

public static boolean isValid(java.lang.String yyyy_mm_dd)
Test to see if the given yyyy-mm-dd is a date as a String is legitimate. must have 4-digit years, and use dashes between the number and no sign Does extensive checks considering leap years, missing days etc.

Parameters:
yyyy_mm_dd - string of form "yyyy-mm-dd". yyyy-mm-dd y-mm-ddBC 2009-12-31 1234-5-31AD 1970/3/3 AD 3.01.12 bc 2000_12_31 It will not accept a date missing the year, month or day field. Spaces and commas are ignored.
Returns:
true if that represents a valid date.

isValid

public static boolean isValid(int yyyy,
                              int mm,
                              int dd)
Test to see if the given yyyy, mm, dd date is legitimate. Does extensive checks considering leap years, missing days etc.

Parameters:
yyyy - -999,999 (BC) to +999,999 (AD)
mm - month 1 to 12 (not 0 to 11 as in Sun's Date), no lead 0.
dd - day 1 to 31, no lead 0.
Returns:
true if yyyy mm dd is a valid date.

isoDayOfWeek

public static int isoDayOfWeek(int ordinal)
Get day of week 1 to 7 for this ordinal according to the ISO standard IS-8601. It is one-based starting with Monday.

Parameters:
ordinal - days since 1970-01-01 to test.
Returns:
day of week 1=Monday to 7=Sunday, 0 for null date. WARNING: not compatible with 1=Calendar.SUNDAY.
See Also:
dayOfWeek(int)

localToday

public static BigDate localToday()
Returns a BigDate object initialised to today's local date. It depends on Java's default TimeZone being configured, and your system clock accurately set to UTC time. Experiment setting your system date/time to various values and making sure you are getting the expected results. Note the date in the created object does not keep updating every time you reference it with methods like getOrdinal or getDD. You always get the date the object was created. It is quite a production to get the local date. Best to ask once and save the today object.

Returns:
BigDate object initialised to today, local time.
See Also:
today(java.util.TimeZone), UTCToday()

monthAbbr

public static java.lang.String monthAbbr(int mm)
Get 3-char abbreviation of a given month of the year.

Parameters:
mm - month number jan = 1
Returns:
abbreviation for month, e.g. "Jan"

monthName

public static java.lang.String monthName(int mm)
Get full name of a given month of the year.

Parameters:
mm - month number jan = 1
Returns:
name of month e.g. "January"

nthXXXDay

public static int nthXXXDay(int which,
                            int dayOfWeek,
                            int yyyy,
                            int mm)
Find the first monday in a given month, the 3rd monday or the last Thursday...

Parameters:
which - 1=first 2=second 3=third 4=fourth 5=last (might be 4th or 5th)
dayOfWeek - 0=Sunday 1=Monday 2=Tuesday 3=Wednesday 4=Thursday 5=Friday 6=Saturday WARNING: not compatible with 1=Calendar.SUNDAY.
yyyy - year of interest.
mm - month 1 to 12 (not 0 to 11 as in Sun's Date), no lead 0.
Returns:
day of month 1..31

ordinalOfnthXXXDay

public static int ordinalOfnthXXXDay(int which,
                                     int dayOfWeek,
                                     int yyyy,
                                     int mm)
Find the first monday in a given month, the 3rd monday or the last Thursday...

Parameters:
which - 1=first 2=second 3=third 4=fourth 5=last (might be 4th or 5th)
dayOfWeek - 0=Sunday 1=Monday 2=Tuesday 3=Wednesday 4=Thursday 5=Friday 6=Saturday WARNING: not compatible with 1=Calendar.SUNDAY.
yyyy - year of interest.
mm - month 1 to 12 (not 0 to 11 as in Sun's Date), no lead 0.
Returns:
day of month 1..31

parseYYYY

public static int parseYYYY(java.lang.String yyyyString)
                     throws java.lang.NumberFormatException
parse a string into yyyy which may have form: 1948 230BC 1234AD It does not allow a space before the BC or AD.

Parameters:
yyyyString - date string.
Returns:
yyyy, negative for BC.
Throws:
java.lang.NumberFormatException - id the string has non-numeric chars.

parseYYYYmmdd

public static BigDate parseYYYYmmdd(java.lang.String incomplete)
Parse a, possibly incomplete, date String of form yyyy-yy-dd or yyyy-mm or yyyy into a BigDate Also handles AD/BC, 1-digit months, 1-digit days and 1, 2 or 3-digit years. Date must be a valid normalised date.

Parameters:
incomplete - Date string, usually of form YYYY-MM-DD, possibly just YYYY-MM or YYYY.
Returns:
BigDate first of year for YYYY or first of month for YYYY-MM, or precise date for YYYY-MM-DD
See Also:
BigDate(String)

toOrdinal

public static int toOrdinal(java.lang.String yyyy_mm_dd)
Convert ISO date string in form YYYY-MM-DD into days since the 1970-01-01. This method lets you convert directly from Gregorian to ordinal without creating a BigDate object. yyyy-mm-dd must be a valid date.

Parameters:
yyyy_mm_dd - iso date string.
Returns:
ordinal, days since 1970-01-01

toOrdinal

public static int toOrdinal(int yyyy,
                            int mm,
                            int dd)
Convert date in form YYYY MM DD into days since the 1970-01-01. This method lets you convert directly from Gregorian to ordinal without creating a BigDate object. yyyy mm dd must be a valid date.

Parameters:
yyyy - -999,999 (BC) to +999,999 (AD)
mm - month 1 to 12 (not 0 to 11 as in Sun's Date), no lead 0.
dd - day 1 to 31, no lead 0.
Returns:
ordinal, days since 1970-01-01.

today

public static BigDate today(java.util.TimeZone timeZone)
Returns a BigDate object initialised to the date right now in the given TimeZone. It depends on your system clock accurately set to UTC time. Experiment setting your system date/time to various values and making sure you are getting the expected results. Note the date in the created object does not keep updating every time you reference it with methods like getOrdinal or getDD. You always get the date the object was created. It is quite a production to get the this date. Best to ask once and save the today object.

Parameters:
timeZone - in which we want to know the today's date.
Returns:
BigDate object initialised to today at given TimeZone.
See Also:
localToday(), UTCToday()

addDays

public final void addDays(int days)
increment this date by a number of days.

Parameters:
days - positive or negative, -1 gets day before this one.

calendarDayOfWeek

public int calendarDayOfWeek()
Get day of week for this BigDate. It is one-based starting with Sunday.

Returns:
day of week 1=Sunday 2=Monday 3=Tuesday 4=Wednesday 5=Thursday 6=Friday 7=Saturday Compatible with Sun's 1=Calendar.SUNDAY Not compatible with BigDate.getDayOfWeek.
See Also:
isoDayOfWeek(int), dayOfWeek(int), getCalendarDayOfWeek()

compareTo

public final int compareTo(java.lang.Object other)
Compare BigDates in ascending date order. Defines default the sort order for BigDate Objects. Compare this BigDate with another BigDate. Compares ordinal. Informally, returns (this-other) or +ve if this is more positive than other.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
other - other BigDate to compare with this one
Returns:
+ve if this>other, 0 if this==other, -ve if this<other
See Also:
compare(int, int, int, int, int, int)

dayOfWeek

public int dayOfWeek()
Get day of week for this BigDate. Is it zero-based starting with Sunday.

Returns:
day of week 0=Sunday 1=Monday 2=Tuesday 3=Wednesday 4=Thursday 5=Friday 6=Saturday WARNING: not compatible with 1=Calendar.SUNDAY
See Also:
calendarDayOfWeek(int), isoDayOfWeek(int), getDayOfWeek()

equals

public final boolean equals(java.lang.Object d)
Compares with another BigDate to see if they refer to the same date.

Overrides:
equals in class java.lang.Object
Parameters:
d - other BigDate to compare with this one.
Returns:
true if BigDate d refers to the same date

getCalendarDayOfWeek

public final int getCalendarDayOfWeek()
Get day of week for this BigDate. Is it one-based starting with Sunday.

Returns:
day of week 1=Sunday 2=Monday 3=Tuesday 4=Wednesday 5=Thursday 6=Friday 7=Saturday Compatible with Sun's 1=Calendar.SUNDAY Not compatible with BigDate.getDayOfWee
See Also:
getISODayOfWeek(), getDayOfWeek(), calendarDayOfWeek(int)

getDD

public final int getDD()
get day of month for this BigDate.

Returns:
day 1 to 31, 0 for null date.

getDDD

public final int getDDD()
Get day number in the year for this BigDate.

Returns:
day number Jan 01 = 1, 1 to 366

getDate

public final java.util.Date getDate(java.util.TimeZone timeZone)
Get java.util.Date object corresponding to this BigDate,

Parameters:
timeZone - We consider this BigDate to have an implied time of 0:00 in this timeZone.
Returns:
Date or null Result is undefined if BigDate is outside the range handled by Date.
See Also:
getLocalTimeStamp(), getUTCTimeStamp(), getTimeStamp(java.util.TimeZone), getUTCDate(), getLocalDate()

getDayOfWeek

public final int getDayOfWeek()
Get day of week for this BigDate. It is zero-based starting with Sunday.

Returns:
day of week 0=Sunday 1=Monday 2=Tuesday 3=Wednesday 4=Thursday 5=Friday 6=Saturday WARNING: not compatible with 1=Calendar.SUNDAY
See Also:
getCalendarDayOfWeek(), getISODayOfWeek(), dayOfWeek(int)

getISODayOfWeek

public final int getISODayOfWeek()
Get day of week 1 to 7 for this BigDate according to the ISO standard IS-8601. It is one-based starting with Monday.

Returns:
day of week 1=Monday to 7=Sunday, 0 for null date. WARNING: not compatible with 1=Calendar.SUNDAY
See Also:
getCalendarDayOfWeek(), getDayOfWeek(), isoDayOfWeek(int)

getISOWeekNumber

public final int getISOWeekNumber()
Get week number 1 to 53 of the year this date falls in, according to the rules of ISO standard IS-8601. A week that lies partly in one year and partly in another is assigned a number in the year in which most of its days lie. This means that week 1 of any year is the week that contains 4 January, or equivalently week 1 of any year is the week that contains the first Thursday in January. Most years have 52 weeks, but years that start on a Thursday and leap years that start on a Wednesday have 53 weeks. Jan 1 may well be in week 53 of the previous year! Only defined for dates on or after 1600 Jan 01. You can find out how many ISO weeks there are per year with new BigDate( year, 12, 31).getISOWeekNumber();

Returns:
week number 1..53, 0 for null or invalid date.
See Also:
Calendar FAQ

getLocalDate

public final java.util.Date getLocalDate()
Get java.util.Date object corresponding to this BigDate. We consider this BigDate to have an implied time of 0:00 local time.

Returns:
Date or null Result is undefined if BigDate is outside the range handled by Date.
See Also:
getLocalTimeStamp()

getLocalTimeStamp

public final long getLocalTimeStamp()
Get milliseconds since 1970-01-01 00:00 GMT for this BigDate. Does not account for leap seconds primarily because we do not know them in advance. N.B. returns long, not int as in many Unix implementations. This the long that a Sun Date constructor wants. We consider this BigDate to have an implied time of 0:00 local time.

Returns:
milliseconds since 1970-01-01 00:00 GMT, or NULL_TIMESTAMP. This is NOT a JDBC Timestamp! You can use this timestamp with java.util.Date.setTime, java.sql.TimeStamp.setTime or java.sql.Date.setTime or in the constructors. To interconvert, just cast.
See Also:
getLocalDate()

getMM

public final int getMM()
Get month of year for this BigDate.

Returns:
month 1 to 12, 0 for null date.

getOrdinal

public final int getOrdinal()
get days since 1970-01-01 for this BigDate. 1970-01-01 = day 0.

Returns:
days since 1970-01-01. This is NOT what you want for the java.util.Date constructor.
See Also:
getLocalTimeStamp(), getUTCTimeStamp(), getTimeStamp(java.util.TimeZone)

getProlepticJulianDay

public final double getProlepticJulianDay()
Returns:
Julian day number of noon of the date BigDate represents. See notes on the Julian Proleptic calendar under the constructor.

getSeason

public final int getSeason()
Get season of year for this BigDate.

Returns:
0=spring (Mar, Apr, May) 1=summer (Jun, Jul, Aug) 2=fall (Sep, Oct, Dec) 3=winter Dec, Jan, Feb

getTimeStamp

public final long getTimeStamp(java.util.TimeZone timeZone)
Get milliseconds since 1970-01-01 00:00 GMT for this BigDate, as at the start of day 0:00. Does not account for leap seconds primarily because we do not know them in advance. N.B. returns long, not int as in many Unix implementations. This the long that a Sun Date constructor wants.

Parameters:
timeZone - We consider this BigDate to have an implied time of 0:00 in this timeZone.
Returns:
milliseconds since 1970-01-01 00:00 GMT, or NULL_TIMESTAMP. This is NOT a JDBC Timestamp! You can use this timestamp with java.util.Date.setTime, java.sql.TimeStamp.setTime or java.sql.Date.setTime or in the constructors. To interconvert, just cast.
See Also:
getDate(java.util.TimeZone), getUTCTimeStamp(), getLocalTimeStamp()

getUTCDate

public final java.util.Date getUTCDate()
Get java.util.Date object corresponding to this BigDate. We consider this BigDate to have an implied time of 0:00 UTC (Greenwich GMT).

Returns:
Date or null Result is undefined if BigDate is outside the range handled by Date.
See Also:
getUTCTimeStamp()

getUTCTimeStamp

public final long getUTCTimeStamp()
Get milliseconds since 1970-01-01 00:00 GMT for this BigDate. Does not account for leap seconds primarily because we do not know them in advance. N.B. returns long, not int as in many Unix implementations. This the long that a Sun Date constructor wants. We consider this BigDate to have an implied time of 0:00 UTC (Greenwich GMT).

Returns:
milliseconds since 1970-01-01 00:00 GMT, or NULL_TIMESTAMP. This is NOT a JDBC Timestamp! You can use this timestamp with java.util.Date.setTime, java.sql.TimeStamp.setTime or java.sql.Date.setTime or in the constructors. To interconvert, just cast.
See Also:
getUTCDate()

getWeekNumber

public final int getWeekNumber()
Get week number 1 to 53 of the year this date falls in. This does NOT follow the rules of ISO standard IS-8601 section 5.5. Week 1 is the first week with any days in the current year. Weeks start on Sunday. Jan 1 and Dec 31 are always considered part of the current year. Only defined for dates on or after 1600 Jan 01.

Returns:
week number 1..53, 0 for null or invalid date.
See Also:
getISOWeekNumber()

getYYYY

public final int getYYYY()
Get year for this BigDate.

Returns:
year -999,999 to 999,999. 0 for null date. negative is BC, positive AD.

hashCode

public final int hashCode()
hashCode for use in Hashtable/HashMap lookup

Overrides:
hashCode in class java.lang.Object
Returns:
the ordinal which is perfectly unique for the date.

nearestXXXDay

public BigDate nearestXXXDay(int dayOfWeek)
Find the BigDate with date closest to this one with the given day of week.

Parameters:
dayOfWeek - 0=Sunday 1=Monday 2=Tuesday 3=Wednesday 4=Thursday 5=Friday 6=Saturday WARNING: not compatible with 1=Calendar.SUNDAY.
Returns:
BigDate object with nearest date to this one with the given day of week.

ordinal

public final int ordinal()
get days since 1970-01-01 for this BigDate. 1970-01-01 = day 0. synomym for getOrdinal. Parallels enum.ordinal

Returns:
days since 1970-01-01. This is NOT what you want for the java.util.Date constructor.
See Also:
getLocalTimeStamp(), getUTCTimeStamp(), getTimeStamp(java.util.TimeZone)

set

public final void set(int ordinal)
Set the ordinal field, and compute the equivalent internal Gregorian yyyy mm dd fields. alias setOrdinal.

Parameters:
ordinal - days since 1970-01-01.

set

public final void set(int yyyy,
                      int mm,
                      int dd)
Set the yyyy mm dd Gregorian fields, and compute the internal ordinal equivalent. yyyy mm dd are checked for validity.

Parameters:
yyyy - -999,999 (BC) to +999,999 (AD)
mm - month 1 to 12 (not 0 to 11 as in Sun's Date), no lead 0.
dd - day 1 to 31, no lead 0.

set

public final void set(int yyyy,
                      int mm,
                      int dd,
                      int how)
Set the Gregorian fields, and compute the ordinal equivalent with the same modifiers CHECK, NORMALIZE, BYPASSCHECK as the constructor. BEWARE! In Java a lead 0 on an integer implies OCTAL.

Parameters:
yyyy - -999,999 (BC) to +999,999 (AD)
mm - month 1 to 12 (not 0 to 11 as in Sun's Date), no lead 0.
dd - day 1 to 31, no lead 0.
how - one of CHECK BYPASSCHECK NORMALIZE NORMALISE

the following are constants, not enums.

See Also:
CHECK, BYPASSCHECK, NORMALIZE, NORMALISE

setDateAtTime

public void setDateAtTime(long utcTimestamp,
                          java.util.TimeZone timeZone)
Sets the date that corresponding to a given utc timestamp at a given TimeZone.

Parameters:
utcTimestamp - milliseconds since 1970 in UTC time. E.g. Date.getTime
timeZone - Timezone you want to know the date in at that time. TimeZone.getDefault() TimeZone.getU

setOrdinal

public final void setOrdinal(int ordinal)
Set the ordinal field, and compute the equivalent internal Gregorian yyyy mm dd fields. alias set.

Parameters:
ordinal - days since 1970-01-01.

toDowMMDDYY

public java.lang.String toDowMMDDYY()
Convert date to a human-readable String [wed mm/dd/yy]

Returns:
this BigDate as a String in form fri 12/31/03

toString

public java.lang.String toString()
Convert date to a human-readable String. Handles BC with trailing _BC.

Overrides:
toString in class java.lang.Object
Returns:
this BigDate as a String in form YYYY-MM-DD ISO 8601:1988 international standard format. NOT final so you can override to suit yourself.

toYYYYString

public java.lang.String toYYYYString()
Convert just year part of date to a human-readable String. Handles BC with trailing BC.

Returns:
this BigDate as a String in form YYYYBC or yyyyy

daysInYearPriorToMonth

protected static int daysInYearPriorToMonth(int mm,
                                            boolean leap)
How many days were there in the year prior to the first day of the given month?

Parameters:
mm - month 1 to 12 (not 0 to 11 as in Sun's Date), no lead 0.
leap - true if you are interested in a leap year.
Returns:
how many days in year prior to the start of that month.

dddToMM

protected static int dddToMM(int ddd,
                             boolean leap)
Convert day number ddd in year to month.

Parameters:
ddd - day number in year Jan 01 = 1, 1 to 366.
leap - true if year of interest is boolean.
Returns:
month that day number would fall in.

jan01OfYear

protected static int jan01OfYear(int yyyy)
Ordinal date of Jan 01 of the given year.

Parameters:
yyyy - year of interest
Returns:
ordinal of Jan 01 of that year.

calcOrdinal

protected final void calcOrdinal()
Convert date in form YYYY MM DD into days since the epoch, leaving results internally.

See Also:
getOrdinal()

normalise

protected final void normalise()
Clean up an invalid date, leaving the results internally e.g. 1954-09-31 -> 1954-10-01. 1954-10-(minus 1) -> 1954-09-30 1954-13-01 -> 1955-01-01. This lets you do year, month or day arithmetic. normalise does not recompute the ordinal.


toGregorian

protected final void toGregorian()
converts ordinal to YYYY MM DD, leaving results internally.