Class OceanusDate
java.lang.Object
io.github.tonywasher.joceanus.oceanus.date.OceanusDate
- All Implemented Interfaces:
Comparable<OceanusDate>
Represents a Date object that is fixed to a particular day. There is no concept of time within
the day Calendar objects that are built to represent the Date are set to noon on the day in
question.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ClockStandard clock.protected static final intThe Hash prime.protected static final intThe Number of months in a Quarter.protected static final intThe Year shift for DateDay Id. -
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new Date and initialise with today's date.OceanusDate(int pYear, int pMonth, int pDay) Construct an explicit Date.OceanusDate(int pYear, int pMonth, int pDay, Locale pLocale) Construct an explicit Date for a locale.OceanusDate(int pYear, Month pMonth, int pDay) Construct an explicit Date.OceanusDate(int pYear, Month pMonth, int pDay, Locale pLocale) Construct an explicit Date for a locale.OceanusDate(OceanusDate pDate) Construct a new Date and initialise from a date.OceanusDate(String pValue) Construct a Date from a formatted string.OceanusDate(String pValue, Locale pLocale) Construct a Date from a formatted string.OceanusDate(String pValue, Locale pLocale, String pFormat) Construct a Date from a formatted string.OceanusDate(LocalDate pDate) Construct a new Date and initialise from a java date.OceanusDate(LocalDate pDate, Locale pLocale) Construct a new Date and initialise from a java date.OceanusDate(Locale pLocale) Construct a new Date and initialise with today's date. -
Method Summary
Modifier and TypeMethodDescriptionvoidadjustBackwardByPeriod(OceanusDatePeriod pPeriod) Adjust the date by a period in a backward direction.voidadjustDay(int iDay) Adjust the date by a number of days.voidadjustField(TemporalUnit iField, int iUnits) Adjust the date by a determined amount.voidadjustForwardByPeriod(OceanusDatePeriod pPeriod) Adjust the date by a period in a forward direction.voidadjustMonth(int iMonth) Adjust the date by a number of months.voidadjustYear(int iYear) Adjust the date by a number of years.intcompareTo(OceanusDate pThat) voidcopyDate(OceanusDate pDate) Copy a date from another DateDay.longdaysUntil(OceanusDate pDate) Calculate the days until the specified date.booleangetDate()Get the Date associated with this object.intgetDay()Get the day of the date.Get the day of the week.intgetId()Get the id of the date.Get the locale associated with this object.intgetMonth()Get the month of the date.Get the month value.intgetYear()Get the year of the date.inthashCode()static booleanisDifferent(OceanusDate pCurr, OceanusDate pNew) Determine whether two DateDay objects differ.voidSet the date format.voidSet locale for the DateDay.toString()
-
Field Details
-
CLOCK
Standard clock. -
HASH_PRIME
protected static final int HASH_PRIMEThe Hash prime.- See Also:
-
SHIFT_ID_YEAR
protected static final int SHIFT_ID_YEARThe Year shift for DateDay Id. This is 9 corresponding to (1 shiftLeft 9 places) = 512- See Also:
-
MONTHS_IN_QUARTER
protected static final int MONTHS_IN_QUARTERThe Number of months in a Quarter.- See Also:
-
-
Constructor Details
-
OceanusDate
public OceanusDate()Construct a new Date and initialise with today's date. -
OceanusDate
Construct a new Date and initialise with today's date.- Parameters:
pLocale- the locale
-
OceanusDate
Construct a new Date and initialise from a java date.- Parameters:
pDate- the java date to initialise from
-
OceanusDate
Construct a new Date and initialise from a java date.- Parameters:
pDate- the java date to initialise frompLocale- the locale for this date
-
OceanusDate
Construct a new Date and initialise from a date.- Parameters:
pDate- the finance date to initialise from
-
OceanusDate
public OceanusDate(int pYear, int pMonth, int pDay) Construct an explicit Date.- Parameters:
pYear- the yearpMonth- the month (1 to 12 etc)pDay- the day of the month
-
OceanusDate
Construct an explicit Date.- Parameters:
pYear- the yearpMonth- the month (Month.JUNE etc)pDay- the day of the month
-
OceanusDate
Construct an explicit Date for a locale.- Parameters:
pYear- the yearpMonth- the month (1 to 12 etc)pDay- the day of the monthpLocale- the locale for this date
-
OceanusDate
Construct an explicit Date for a locale.- Parameters:
pYear- the yearpMonth- the month (Month.JUNE etc)pDay- the day of the monthpLocale- the locale for this date
-
OceanusDate
Construct a Date from a formatted string.- Parameters:
pValue- the formatted string
-
OceanusDate
Construct a Date from a formatted string.- Parameters:
pValue- the formatted stringpLocale- the locale for this date
-
OceanusDate
Construct a Date from a formatted string.- Parameters:
pValue- the formatted stringpLocale- the locale for this datepFormat- the format to use for parsing
-
-
Method Details
-
getYear
public int getYear()Get the year of the date.- Returns:
- the year of the date
-
getMonth
public int getMonth()Get the month of the date.- Returns:
- the month of the date
-
getDay
public int getDay()Get the day of the date.- Returns:
- the day of the date
-
getDayOfWeek
Get the day of the week.- Returns:
- the day of the week
-
getMonthValue
Get the month value.- Returns:
- the month value
-
getId
public int getId()Get the id of the date. This is a unique integer representation of the date usable as an id for the date.- Returns:
- the id of the date
-
getDate
Get the Date associated with this object.- Returns:
- the date
-
getLocale
Get the locale associated with this object.- Returns:
- the java locale
-
setLocale
Set locale for the DateDay.- Parameters:
pLocale- the locale
-
setFormat
Set the date format.- Parameters:
pFormat- the format string
-
adjustYear
public void adjustYear(int iYear) Adjust the date by a number of years.- Parameters:
iYear- the number of years to adjust by
-
adjustMonth
public void adjustMonth(int iMonth) Adjust the date by a number of months.- Parameters:
iMonth- the number of months to adjust by
-
adjustDay
public void adjustDay(int iDay) Adjust the date by a number of days.- Parameters:
iDay- the number of days to adjust by
-
adjustField
Adjust the date by a determined amount.- Parameters:
iField- the field to adjustiUnits- the number of units to adjust by
-
adjustForwardByPeriod
Adjust the date by a period in a forward direction.- Parameters:
pPeriod- the period to adjust by
-
adjustBackwardByPeriod
Adjust the date by a period in a backward direction.- Parameters:
pPeriod- the period to adjust by
-
daysUntil
Calculate the days until the specified date.- Parameters:
pDate- the date for which to days until- Returns:
- the days until that date
-
copyDate
Copy a date from another DateDay.- Parameters:
pDate- the date to copy from
-
toString
-
compareTo
- Specified by:
compareToin interfaceComparable<OceanusDate>
-
equals
-
hashCode
public int hashCode() -
isDifferent
Determine whether two DateDay objects differ.- Parameters:
pCurr- The current DatepNew- The new Date- Returns:
trueif the objects differ,falseotherwise
-