Class Year
- All Implemented Interfaces:
Serializable, Comparable<Year>
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:
-
Field Summary
Fields inherited from class CalendarObject
calendarKey -
Method Summary
Modifier and TypeMethodDescriptionatDay(int day) intbooleanReturns whether the given non-nullDayis part of this year.booleanReturns whether the given non-nullInstant, is inside this year.booleancontainsNot(Day day) Returns whether the given non-nullDayis not part of this year.booleancontainsNot(Instant instant) Returns whether the given non-nullInstant, is not inside this year.intdifferenceWith(Year other) Returns the difference of the numerical year values of this year and the given non-nullYear.booleanfirstDay()longGets the total number of milliseconds from the start of the Lukashian Calendar, up to the final point of this year.longGets 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.longGets the total number of milliseconds from the start of the Lukashian Calendar, up to the final point of the previous year or 0 if this is the very first year.intGets the number of days in this year.intReturns the integer value of thisYear, i.e. which year this is.inthashCode()booleanReturns whether this year is after the given non-nullYear.booleanReturns whether this year is before the given non-nullYear.booleanisSameOrAfter(Year other) Returns whether this year is the same or after the given non-nullYear.booleanisSameOrBefore(Year other) Returns whether this year is the same or before the given non-nullYear.lastDay()longGets the total number of milliseconds from the start of this year, up to the final point of this year.minusYears(int yearsToSubtract) Returns a newYearthat represents this year minus the given amount of years.next()Returns a newYearthat represents the year succeeding this year.static Yearnow()Returns the currentYearof the default calendar instance.static Yearnow(int calendarKey) Returns the currentYearof the given calendar instance.static Yearof(int year) Creates a newYearrepresenting the given year of the default calendar instance.static Yearof(int year, int calendarKey) Creates a newYearrepresenting the given year of the given calendar instance.plusYears(int yearsToAdd) Returns a newYearthat represents this year plus the given amount of years.previous()Returns a newYearthat represents the year preceding this year.toString()Methods inherited from class CalendarObject
checkSameKeyAs, getCalendarKey
-
Method Details
-
minusYears
Returns a newYearthat represents this year minus the given amount of years.- Throws:
LukashianException- when the result would be year 0 or lower
-
plusYears
-
previous
Returns a newYearthat represents the year preceding this year.- Throws:
LukashianException- when the result would be year 0 or lower
-
next
-
atDay
- Throws:
LukashianException- when the given day number does not exist for thisYear
-
firstDay
-
lastDay
-
firstInstant
-
lastInstant
-
isBefore
-
isSameOrBefore
-
isAfter
-
isSameOrAfter
-
contains
-
containsNot
-
contains
-
containsNot
-
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 thisYear, 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 or 0 if this is the very first 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
Returns the difference of the numerical year values of this year and the given non-nullYear. 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
Creates a newYearrepresenting the given year of the given calendar instance.- Throws:
LukashianException- when the given year is 0 or lower or when the given calendar instance is not registered- See Also:
-
of
Creates a newYearrepresenting the given year of the default calendar instance.- Throws:
LukashianException- when the given year is 0 or lower- See Also:
-
now
Returns the currentYearof the given calendar instance.- Throws:
LukashianException- when the given calendar instance is not registered- See Also:
-
now
-
compareTo
- Specified by:
compareToin interfaceComparable<Year>
-
hashCode
-
equals
-
toString
-