Class Year
- All Implemented Interfaces:
Serializable
,Comparable<Year>
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 Summary
Modifier and TypeMethodDescriptionatDay
(int day) int
boolean
Returns whether the given non-nullDay
, is part of this year.boolean
Returns whether the given non-nullInstant
, is inside this year.boolean
containsNot
(Day day) Returns whether the given non-nullDay
, is not part of this year.boolean
containsNot
(Instant instant) Returns whether the given non-nullInstant
, is not inside this year.int
differenceWith
(Year other) Returns the difference of the numerical year values of this year and the given non-nullYear
.boolean
firstDay()
long
Gets the total number of milliseconds from the start of the Lukashian Calendar, up to the final point of this year.long
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.long
Gets the total number of milliseconds from the start of the Lukashian Calendar, up to the final point of the previous year.int
Gets the number of days in this year.int
Returns the integer value of thisYear
, i.e. which year this is.int
hashCode()
boolean
Returns whether this year is after the given non-nullYear
.boolean
Returns whether this year is before the given non-nullYear
.boolean
isSameOrAfter
(Year other) Returns whether this year is the same or after the given non-nullYear
.boolean
isSameOrBefore
(Year other) Returns whether this year is the same or before the given non-nullYear
.lastDay()
long
Gets the total number of milliseconds from the start of this year, up to the final point of this year.minusYears
(int yearsToSubtract) Returns a newYear
that represents this year minus the given amount of years.next()
Returns a newYear
that represents the year succeeding this year.static Year
now()
Returns the currentYear
.static Year
of
(int year) Creates a newYear
representing the given year.plusYears
(int yearsToAdd) Returns a newYear
that represents this year plus the given amount of years.previous()
Returns a newYear
that represents the year preceding this year.toString()
-
Method Details
-
minusYears
Returns a newYear
that represents this year minus the given amount of years.- Throws:
LukashianException
- when the result would be year 0 or lower
-
plusYears
Returns a newYear
that represents this year plus the given amount of years. -
previous
Returns a newYear
that represents the year preceding this year.- Throws:
LukashianException
- when the result would be year 0 or lower
-
next
Returns a newYear
that represents the year succeeding this year. -
atDay
- Throws:
LukashianException
- when the given day number does not exist for thisYear
-
firstDay
-
lastDay
-
firstInstant
-
lastInstant
-
isBefore
Returns whether this year is before the given non-nullYear
. -
isSameOrBefore
Returns whether this year is the same or before the given non-nullYear
. -
isAfter
Returns whether this year is after the given non-nullYear
. -
isSameOrAfter
Returns whether this year is the same or after the given non-nullYear
. -
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. -
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 newYear
representing the given year.- Throws:
LukashianException
- when the given year is 0 or lower
-
now
Returns the currentYear
. -
compareTo
- Specified by:
compareTo
in interfaceComparable<Year>
-
hashCode
public int hashCode() -
equals
-
toString
-