Class Day
- All Implemented Interfaces:
Serializable,Comparable<Day>
StandardEarthMillisecondStoreDataProvider.
The first day of every year is day 1. A day is part of the year that it starts in, even if it finishes in the next year.
By definition, the exact point at which a day starts belongs to that day, not to the previous day, which ends at that point. So, a day runs from its start (inclusive) to its end (exclusive).
In the Lukashian Calendar, the length of a day in milliseconds is not constant. Instead, it accurately represents the actual length of a particular day in astronomical terms. Due to astronomical and planetary developments, this duration is not constant. Since the same is true for years (a year accurately represents the actual length of a particular year in astronomical terms), a day is not necessarily contained in a single year. In fact, it is very unlikely that the turn of a year coincides with the turn of a day. Therefore, a day is defined to be part of the year in which it started.
The very first day of the calendar starts at the same point as the very first year. This means that the turn of every single day happens at the position of the planet at the start of the calendar.
A Day keeps track of the total number of milliseconds that have taken place from the start of the Lukashian Calendar (Lukashian epoch) until
the final point of this day. This value is called "epoch milliseconds". This information allows for determining which year a day is in and how to
do various calculations. A Day also keeps track of the epoch milliseconds of the previous Day, for calculation purposes.
This means that a Day knows how many milliseconds it lasts, by subtracting the two.
Internally, a Day keeps track of its epoch value ("epoch day"). This value represents which day this is since the start of the Lukashian
Calendar, regardless of the year. This value also starts at 1, like years and days within years, 1 being the very first day since the start of
the calendar.
Day is an immutable object. New instances are always created when calling one of the mutation methods.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionatTime(int beeps) Returns a newInstantthat represents the instant that occurs after the given proportion of this day has passed.atTime(org.apache.commons.numbers.fraction.BigFraction proportionOfDay) Returns a newInstantthat represents the instant that occurs after the given proportion of this day has passed.intbooleanReturns whether the given non-nullInstant, is inside this day.booleancontainsNot(Instant instant) Returns whether the given non-nullInstant, is not inside this day.intdifferenceWith(Day other) Returns the amount of days between this day and the given non-nullDay, directionally.booleanintReturns the integer value of thisDay, i.e. which day of the year this is.Returns the year that thisDayends in.intReturns which day this is since the start of the Lukashian Calendar, regardless of the year.longGets the total number of milliseconds from the start of the Lukashian Calendar, up to the final point of this day.longGets the total number of milliseconds from the start of the Lukashian Calendar, up to the first point of this day or 1 if this is the very first day of the calendar.longGets the total number of milliseconds from the start of the Lukashian Calendar, up to the final point of the previous day.org.apache.commons.numbers.fraction.BigFractiongetYear()Returns the year of thisDay, which is the year this day starts in.inthashCode()booleanReturns whether this day is after the given non-nullDay.booleanReturns whether this day is before the given non-nullDay.booleanReturns whether this day is in the given non-nullYear.booleanReturns whether this day is not in the given non-nullYear.booleanisSameOrAfter(Day other) Returns whether this day is the same or after the given non-nullDay.booleanisSameOrBefore(Day other) Returns whether this day is the same or before the given non-nullDay.longGets the total number of milliseconds from the start of this day, up to the final point of this day.minusDays(int daysToSubtract) Returns a newDaythat represents this day minus the given amount of days.minusYears(int yearsToSubtract) Returns a newDaythat represents this day's number on this day's year minus the given amount of years, for example, if this day represents day number 10 of its year, then calling this method will return an day that represents day number 10 of the resulting year.next()Returns a newDaythat represents the day succeeding this day.static Daynow()Returns the currentDay.static Dayof(int epochDay) Creates a newDayrepresenting the given epoch day, i.e. the number of the day since the start of the calendar, irrespective of the year that the day is in, e.g.static Dayof(int year, int day) Creates a newDayrepresenting the given day in the given year.static DayCreates a newDayrepresenting the given day in the given year.plusDays(int daysToAdd) Returns a newDaythat represents this day plus the given amount of days.plusYears(int yearsToAdd) Returns a newDaythat represents this day's number on this day's year plus the given amount of years, for example, if this day represents day number 10 of its year, then calling this method will return an day that represents day number 10 of the resulting year.previous()Returns a newDaythat represents the day preceding this day.toString()
-
Method Details
-
minusYears
Returns a newDaythat represents this day's number on this day's year minus the given amount of years, for example, if this day represents day number 10 of its year, then calling this method will return an day that represents day number 10 of the resulting year.- Throws:
LukashianException- when the result would be before the start of the Lukashian Calendar or when the resulting year does not have a day with this day's number
-
plusYears
Returns a newDaythat represents this day's number on this day's year plus the given amount of years, for example, if this day represents day number 10 of its year, then calling this method will return an day that represents day number 10 of the resulting year.- Throws:
LukashianException- when the resulting year does not have a day with this day's number
-
minusDays
Returns a newDaythat represents this day minus the given amount of days. This might result in aDaythat is in a different year.- Throws:
LukashianException- when the result would be before the start of the Lukashian Calendar
-
plusDays
-
previous
Returns a newDaythat represents the day preceding this day.- Throws:
LukashianException- when the result would be before the start of the Lukashian Calendar
-
next
Returns a newDaythat represents the day succeeding this day. -
atTime
Returns a newInstantthat represents the instant that occurs after the given proportion of this day has passed.- Throws:
LukashianException- when the given proportion is not between 0 (inclusive) and 1 (exclusive).
-
atTime
Returns a newInstantthat represents the instant that occurs after the given proportion of this day has passed.- Throws:
LukashianException- when the given proportion is not between 0 (inclusive) and 9999 (inclusive).
-
firstInstant
-
lastInstant
-
isBefore
Returns whether this day is before the given non-nullDay. -
isSameOrBefore
Returns whether this day is the same or before the given non-nullDay. -
isAfter
Returns whether this day is after the given non-nullDay. -
isSameOrAfter
Returns whether this day is the same or after the given non-nullDay. -
contains
Returns whether the given non-nullInstant, is inside this day. -
containsNot
Returns whether the given non-nullInstant, is not inside this day. -
isIn
Returns whether this day is in the given non-nullYear. -
isNotIn
Returns whether this day is not in the given non-nullYear. -
lengthInMilliseconds
public long lengthInMilliseconds()Gets the total number of milliseconds from the start of this day, up to the final point of this day. This number varies from day to day, depending on astronomical and planetary developments. -
getEpochDay
public int getEpochDay()Returns which day this is since the start of the Lukashian Calendar, regardless of the year. This value starts at 1, consistent with years and days within years. Epoch day 1 is the very first day of the calendar. -
getEpochMilliseconds
public long getEpochMilliseconds()Gets the total number of milliseconds from the start of the Lukashian Calendar, up to the final point of this day. -
getEpochMillisecondsPreviousDay
public long getEpochMillisecondsPreviousDay()Gets the total number of milliseconds from the start of the Lukashian Calendar, up to the final point of the previous day. -
getEpochMillisecondsAtStartOfDay
public long getEpochMillisecondsAtStartOfDay()Gets the total number of milliseconds from the start of the Lukashian Calendar, up to the first point of this day or 1 if this is the very first day of the calendar. -
getYear
Returns the year of thisDay, which is the year this day starts in. -
getEndYear
Returns the year that thisDayends in. This is not necessarily the same year as the one in which this day starts. -
getDayNumber
public int getDayNumber()Returns the integer value of thisDay, i.e. which day of the year this is. -
getLengthOfBeepInMilliseconds
public org.apache.commons.numbers.fraction.BigFraction getLengthOfBeepInMilliseconds() -
differenceWith
Returns the amount of days between this day and the given non-nullDay, directionally. Therefore, if this day is after the other day, the result will be a positive number. If this day is before the other day, the result will be a negative number. If they represent the same day, the result will be 0. -
of
Creates a newDayrepresenting the given epoch day, i.e. the number of the day since the start of the calendar, irrespective of the year that the day is in, e.g. 'day 5000 since the epoch'.- Throws:
LukashianException- when the given epoch day is 0 or lower
-
of
Creates a newDayrepresenting the given day in the given year.- Throws:
LukashianException- when the given day does not exist for the given year
-
of
Creates a newDayrepresenting the given day in the given year.- Throws:
LukashianException- when the given year is 0 or lower or when the given day does not exist for the given year
-
now
Returns the currentDay. -
compareTo
- Specified by:
compareToin interfaceComparable<Day>
-
hashCode
public int hashCode() -
equals
-
toString
-