Package org.lukashian

Class Year

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

public final class Year extends Object implements Comparable<Year>, Serializable
Represents a year in the Lukashian Calendar Mechanism. For the meaning of a year in the standard implementation of the Lukashian Calendar, see StandardEarthMillisecondStoreDataProvider.

The first year is year 1 and years before year 1 are not defined. This is consistent with the numbering of days, since they also start at 1. Also, there's a subtle difference between numbering and counting and when it comes to years, numbering is more appropriate, since numbering is giving each year a numeric designation.

By definition, the exact point at which a year starts belongs to that year, not to the previous year, which ends at that point. So, a year runs from its start (inclusive) to its end (exclusive).

In the Lukashian Calendar, the length of a year in milliseconds is not constant. Instead, it accurately represents the actual length of a particular year in astronomical terms. Due to astronomical and planetary developments, this duration is not constant. Since the same is true for days (a day accurately represents the actual length of a particular day 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.

A Year 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 year. This value is called "epoch milliseconds". This information allows for determining which year a day is in and how to do various calculations. A Year also keeps track of the epoch milliseconds of the previous Year, for calculation purposes. This means that a Year knows how many milliseconds it lasts, by subtracting the two.

Year is an immutable object. New instances are always created when calling one of the mutation methods.

See Also:
  • Method Details

    • minusYears

      public Year minusYears(int yearsToSubtract)
      Returns a new Year that represents this year minus the given amount of years.
      Throws:
      LukashianException - when the result would be year 0 or lower
    • plusYears

      public Year plusYears(int yearsToAdd)
      Returns a new Year that represents this year plus the given amount of years.
    • previous

      public Year previous()
      Returns a new Year that represents the year preceding this year.
      Throws:
      LukashianException - when the result would be year 0 or lower
    • next

      public Year next()
      Returns a new Year that represents the year succeeding this year.
    • atDay

      public Day atDay(int day)
      Returns a new Day that represents the Day of this year that is denoted by the given day number.
      Throws:
      LukashianException - when the given day number does not exist for this Year
    • firstDay

      public Day firstDay()
      Returns a new Day that represents the first Day of this year.
    • lastDay

      public Day lastDay()
      Returns a new Day that represents the last Day of this year. Please note that this Day may end in the next year.
    • firstInstant

      public Instant firstInstant()
      Returns a new Instant that represents the first Instant of this year. This is not necessarily at the start of a day.
    • lastInstant

      public Instant lastInstant()
      Returns a new Instant that represents the last Instant of this year. This is not necessarily at the end of a day.
    • isBefore

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

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

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

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

      public boolean contains(Day day)
      Returns whether the given non-null Day, is part of this year. A Day is part of a year if it started in that year.
    • containsNot

      public boolean containsNot(Day day)
      Returns whether the given non-null Day, is not part of this year. A Day is part of a year if it started in that year.
    • contains

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

      Please note that, even when the Day of the given Instant starts within this year, the time component of the Instant may still cause the Instant to not be part of this year, returning false.

    • containsNot

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

      Please note that, even when the Day of the given Instant does not start within this year, the time component of the Instant may still cause the Instant to be part of this year, returning false.

    • lengthInMilliseconds

      public long lengthInMilliseconds()
      Gets the total number of milliseconds from the start of this year, up to the final point of this year. This number varies from year to year, depending on astronomical and planetary developments.
    • getNumberOfDays

      public int getNumberOfDays()
      Gets the number of days in this year.
    • getYearNumber

      public int getYearNumber()
      Returns the integer value of this Year, i.e. which year this is.
    • getEpochMilliseconds

      public long getEpochMilliseconds()
      Gets the total number of milliseconds from the start of the Lukashian Calendar, up to the final point of this year.
    • getEpochMillisecondsPreviousYear

      public long getEpochMillisecondsPreviousYear()
      Gets the total number of milliseconds from the start of the Lukashian Calendar, up to the final point of the previous year.
    • getEpochMillisecondsAtStartOfYear

      public long getEpochMillisecondsAtStartOfYear()
      Gets the total number of milliseconds from the start of the Lukashian Calendar, up to the first point of this year or 1 if this is the very first year.
    • differenceWith

      public int differenceWith(Year other)
      Returns the difference of the numerical year values of this year and the given non-null Year. Therefore, if this year has a higher numerical year value than the other year, the result will be a positive number. If this year has a lower numerical year value than the other year, the result will be a negative number. If they represent the same year, the result will be 0.
    • of

      public static Year of(int year)
      Creates a new Year representing the given year.
      Throws:
      LukashianException - when the given year is 0 or lower
    • now

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

      public int compareTo(Year other)
      Specified by:
      compareTo in interface Comparable<Year>
    • 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