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 newInstant
that represents the instant that occurs after the given proportion of this day has passed.atTime
(org.apache.commons.numbers.fraction.BigFraction proportionOfDay) Returns a newInstant
that represents the instant that occurs after the given proportion of this day has passed.int
boolean
Returns whether the given non-nullInstant
, is inside this day.boolean
containsNot
(Instant instant) Returns whether the given non-nullInstant
, is not inside this day.int
differenceWith
(Day other) Returns the amount of days between this day and the given non-nullDay
, directionally.boolean
int
Returns the integer value of thisDay
, i.e. which day of the year this is.Returns the year that thisDay
ends in.int
Returns which day this is since the start of the Lukashian Calendar, regardless of the year.long
Gets the total number of milliseconds from the start of the Lukashian Calendar, up to the final point of this day.long
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.long
Gets 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.BigFraction
getYear()
Returns the year of thisDay
, which is the year this day starts in.int
hashCode()
boolean
Returns whether this day is after the given non-nullDay
.boolean
Returns whether this day is before the given non-nullDay
.boolean
Returns whether this day is in the given non-nullYear
.boolean
Returns whether this day is not in the given non-nullYear
.boolean
isSameOrAfter
(Day other) Returns whether this day is the same or after the given non-nullDay
.boolean
isSameOrBefore
(Day other) Returns whether this day is the same or before the given non-nullDay
.long
Gets the total number of milliseconds from the start of this day, up to the final point of this day.minusDays
(int daysToSubtract) Returns a newDay
that represents this day minus the given amount of days.minusYears
(int yearsToSubtract) Returns a newDay
that 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 newDay
that represents the day succeeding this day.static Day
now()
Returns the currentDay
.static Day
of
(int epochDay) Creates a newDay
representing 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 Day
of
(int year, int day) Creates a newDay
representing the given day in the given year.static Day
Creates a newDay
representing the given day in the given year.plusDays
(int daysToAdd) Returns a newDay
that represents this day plus the given amount of days.plusYears
(int yearsToAdd) Returns a newDay
that 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 newDay
that represents the day preceding this day.toString()
-
Method Details
-
minusYears
Returns a newDay
that 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 newDay
that 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 newDay
that represents this day minus the given amount of days. This might result in aDay
that is in a different year.- Throws:
LukashianException
- when the result would be before the start of the Lukashian Calendar
-
plusDays
-
previous
Returns a newDay
that represents the day preceding this day.- Throws:
LukashianException
- when the result would be before the start of the Lukashian Calendar
-
next
Returns a newDay
that represents the day succeeding this day. -
atTime
Returns a newInstant
that 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 newInstant
that 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 thisDay
ends 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 newDay
representing 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 newDay
representing the given day in the given year.- Throws:
LukashianException
- when the given day does not exist for the given year
-
of
Creates a newDay
representing 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:
compareTo
in interfaceComparable<Day>
-
hashCode
public int hashCode() -
equals
-
toString
-