Package org.lukashian

Class Day

java.lang.Object
org.lukashian.Day
All Implemented Interfaces:
Serializable, Comparable<Day>

public final class Day extends Object implements Comparable<Day>, Serializable
Represents a day in the Lukashian Calendar Mechanism. For the meaning of a day in the standard implementation of the Lukashian Calendar, see 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 Type
    Method
    Description
    atTime(int beeps)
    Returns a new Instant 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 new Instant that represents the instant that occurs after the given proportion of this day has passed.
    int
    compareTo(Day other)
     
    boolean
    contains(Instant instant)
    Returns whether the given non-null Instant, is inside this day.
    boolean
    Returns whether the given non-null Instant, is not inside this day.
    int
    Returns the amount of days between this day and the given non-null Day, directionally.
    boolean
    equals(Object object)
     
    Returns a new Instant that represents the first Instant of this day.
    int
    Returns the integer value of this Day, i.e. which day of the year this is.
    Returns the year that this Day 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
    Returns the length of one beep on this Day, i.e. one-ten-thousandth of this Day, in milliseconds.
    Returns the year of this Day, which is the year this day starts in.
    int
     
    boolean
    isAfter(Day other)
    Returns whether this day is after the given non-null Day.
    boolean
    isBefore(Day other)
    Returns whether this day is before the given non-null Day.
    boolean
    isIn(Year year)
    Returns whether this day is in the given non-null Year.
    boolean
    isNotIn(Year year)
    Returns whether this day is not in the given non-null Year.
    boolean
    Returns whether this day is the same or after the given non-null Day.
    boolean
    Returns whether this day is the same or before the given non-null Day.
    Returns a new Instant that represents the last Instant of this day.
    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 new Day that represents this day minus the given amount of days.
    minusYears(int yearsToSubtract)
    Returns a new Day 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.
    Returns a new Day that represents the day succeeding this day.
    static Day
    now()
    Returns the current Day.
    static Day
    of(int epochDay)
    Creates a new Day 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 new Day representing the given day in the given year.
    static Day
    of(Year year, int day)
    Creates a new Day representing the given day in the given year.
    plusDays(int daysToAdd)
    Returns a new Day that represents this day plus the given amount of days.
    plusYears(int yearsToAdd)
    Returns a new Day 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.
    Returns a new Day that represents the day preceding this day.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • minusYears

      public Day minusYears(int yearsToSubtract)
      Returns a new Day 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

      public Day plusYears(int yearsToAdd)
      Returns a new Day 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

      public Day minusDays(int daysToSubtract)
      Returns a new Day that represents this day minus the given amount of days. This might result in a Day that is in a different year.
      Throws:
      LukashianException - when the result would be before the start of the Lukashian Calendar
    • plusDays

      public Day plusDays(int daysToAdd)
      Returns a new Day that represents this day plus the given amount of days. This might result in a Day that is in a different year.
    • previous

      public Day previous()
      Returns a new Day that represents the day preceding this day.
      Throws:
      LukashianException - when the result would be before the start of the Lukashian Calendar
    • next

      public Day next()
      Returns a new Day that represents the day succeeding this day.
    • atTime

      public Instant atTime(org.apache.commons.numbers.fraction.BigFraction proportionOfDay)
      Returns a new Instant 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

      public Instant atTime(int beeps)
      Returns a new Instant 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

      public Instant firstInstant()
      Returns a new Instant that represents the first Instant of this day.
    • lastInstant

      public Instant lastInstant()
      Returns a new Instant that represents the last Instant of this day.
    • isBefore

      public boolean isBefore(Day other)
      Returns whether this day is before the given non-null Day.
    • isSameOrBefore

      public boolean isSameOrBefore(Day other)
      Returns whether this day is the same or before the given non-null Day.
    • isAfter

      public boolean isAfter(Day other)
      Returns whether this day is after the given non-null Day.
    • isSameOrAfter

      public boolean isSameOrAfter(Day other)
      Returns whether this day is the same or after the given non-null Day.
    • contains

      public boolean contains(Instant instant)
      Returns whether the given non-null Instant, is inside this day.
    • containsNot

      public boolean containsNot(Instant instant)
      Returns whether the given non-null Instant, is not inside this day.
    • isIn

      public boolean isIn(Year year)
      Returns whether this day is in the given non-null Year.
    • isNotIn

      public boolean isNotIn(Year year)
      Returns whether this day is not in the given non-null Year.
    • 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

      public Year getYear()
      Returns the year of this Day, which is the year this day starts in.
    • getEndYear

      public Year getEndYear()
      Returns the year that this Day 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 this Day, i.e. which day of the year this is.
    • getLengthOfBeepInMilliseconds

      public org.apache.commons.numbers.fraction.BigFraction getLengthOfBeepInMilliseconds()
      Returns the length of one beep on this Day, i.e. one-ten-thousandth of this Day, in milliseconds. Since the result is not a whole number, is it represented as a BigFraction.
    • differenceWith

      public int differenceWith(Day other)
      Returns the amount of days between this day and the given non-null Day, 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

      public static Day of(int epochDay)
      Creates a new Day 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

      public static Day of(Year year, int day)
      Creates a new Day representing the given day in the given year.
      Throws:
      LukashianException - when the given day does not exist for the given year
    • of

      public static Day of(int year, int day)
      Creates a new Day 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

      public static Day now()
      Returns the current Day.
    • compareTo

      public int compareTo(Day other)
      Specified by:
      compareTo in interface Comparable<Day>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object