Class PersianChronology
- All Implemented Interfaces:
java.lang.Comparable<java.time.chrono.Chronology>,java.time.chrono.Chronology
@Immutable
public final class PersianChronology
extends java.time.chrono.AbstractChronology
Length of each month is between 29 to 31 days. Details of each month is implemented in
PersianMonth enum.
Normal yeras have 365 days and leap years have 366 days.
This is an immutable and thread-safe enum.
- Author:
- Mahmoud Fathi
-
Field Summary
Fields Modifier and Type Field Description static PersianChronologyINSTANCESingle instance of this class. -
Method Summary
Modifier and Type Method Description PersianDatedate(int prolepticYear, int month, int dayOfMonth)Obtains a local date in this chronology from the proleptic-year, month-of-year and day-of-month fields.PersianDatedate(java.time.temporal.TemporalAccessor temporal)Obtains a local date in this chronology from another temporal object.PersianDatedateEpochDay(long epochDay)Obtains a local date in this chronology from the epoch-day.PersianDatedateYearDay(int prolepticYear, int dayOfYear)Obtains a local date in this chronology from the proleptic-year and day-of-year fields.java.time.chrono.EraeraOf(int eraValue)Creates the chronology era object from the numeric value.java.util.List<java.time.chrono.Era>eras()Gets the list of eras for the chronology.java.lang.StringgetCalendarType()Gets the calendar type of the Persian calendar.java.lang.StringgetId()Gets the ID of the chronology.booleanisLeapYear(long year)Returns true ifyearis a leap year in Persian calendar.intprolepticYear(java.time.chrono.Era era, int yearOfEra)Calculates the proleptic-year given the era and year-of-era.java.time.temporal.ValueRangerange(java.time.temporal.ChronoField field)Gets the range of valid values for the specified field.Methods inherited from class java.time.chrono.AbstractChronology
compareTo, equals, hashCode, resolveDate, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.time.chrono.Chronology
date, dateNow, dateNow, dateNow, dateYearDay, epochSecond, epochSecond, getDisplayName, localDateTime, period, zonedDateTime, zonedDateTime
-
Field Details
-
INSTANCE
Single instance of this class.
-
-
Method Details
-
getId
public java.lang.String getId()Gets the ID of the chronology.- Returns:
- the chronology ID, non-null
- See Also:
getCalendarType()
-
getCalendarType
public java.lang.String getCalendarType()Gets the calendar type of the Persian calendar.- Returns:
- the calendar system type; non-null if the calendar has a standard type, otherwise null
- See Also:
getId()
-
date
Obtains a local date in this chronology from the proleptic-year, month-of-year and day-of-month fields.- Parameters:
prolepticYear- the chronology proleptic-yearmonth- the chronology month-of-yeardayOfMonth- the chronology day-of-month- Returns:
- the local date in this chronology, not null
- Throws:
java.time.DateTimeException- if unable to create the date
-
dateYearDay
Obtains a local date in this chronology from the proleptic-year and day-of-year fields.- Parameters:
prolepticYear- the chronology proleptic-yeardayOfYear- the chronology day-of-year- Returns:
- the local date in this chronology, not null
- Throws:
java.time.DateTimeException- if unable to create the date
-
dateEpochDay
Obtains a local date in this chronology from the epoch-day.The definition of
EPOCH_DAYis the same for all calendar systems, thus it can be used for conversion.- Parameters:
epochDay- the epoch day- Returns:
- the local date in this chronology, not null
- Throws:
java.time.DateTimeException- if unable to create the date
-
date
Obtains a local date in this chronology from another temporal object.This obtains a date in this chronology based on the specified temporal. A
TemporalAccessorrepresents an arbitrary set of date and time information, which this factory converts to an instance ofChronoLocalDate.The conversion typically uses the
EPOCH_DAYfield, which is standardized across calendar systems.This method matches the signature of the functional interface
TemporalQueryallowing it to be used as a query via method reference,aChronology::date.- Parameters:
temporal- the temporal object to convert, not null- Returns:
- the local date in this chronology, not null
- Throws:
java.time.DateTimeException- if unable to create the date- See Also:
ChronoLocalDate.from(TemporalAccessor)
-
isLeapYear
public boolean isLeapYear(long year)Returns true ifyearis a leap year in Persian calendar.- Parameters:
year- the year to be checked whether is a leap year or not. For valid range, checkrange(ChronoField YEAR).- Returns:
- true if
yearis a leap year in Persian calendar
-
prolepticYear
public int prolepticYear(java.time.chrono.Era era, int yearOfEra)Calculates the proleptic-year given the era and year-of-era.This combines the era and year-of-era into the single proleptic-year field.
- Parameters:
era- the era of the correct type for the chronology, not nullyearOfEra- the chronology year-of-era- Returns:
- the proleptic-year
- Throws:
java.time.DateTimeException- if unable to convert to a proleptic-year, such as if the year is invalid for the erajava.lang.ClassCastException- if theerais not of the correct type for the chronology
-
eraOf
public java.time.chrono.Era eraOf(int eraValue)Creates the chronology era object from the numeric value.The era is, conceptually, the largest division of the time-line. Most calendar systems have a single epoch dividing the time-line into two eras. However, some have multiple eras, such as one for the reign of each leader. The exact meaning is determined by the chronology according to the following constraints.
This method returns the singleton era of the correct type for the specified era value.
- Parameters:
eraValue- the era value- Returns:
- the calendar system era, not null
- Throws:
java.time.DateTimeException- if unable to create the era
-
eras
public java.util.List<java.time.chrono.Era> eras()Gets the list of eras for the chronology.- Returns:
- the list of eras for the chronology, may be immutable, not null
-
range
public java.time.temporal.ValueRange range(java.time.temporal.ChronoField field)Gets the range of valid values for the specified field.All fields can be expressed as a
longinteger. This method returns an object that describes the valid range for that value.Note that the result only describes the minimum and maximum valid values and it is important not to read too much into them. For example, there could be values within the range that are invalid for the field.
This method will return a result whether or not the chronology supports the field.
- Parameters:
field- the field to get the range for, not null- Returns:
- the range of valid values for the field, not null
- Throws:
java.time.DateTimeException- if the range for the field cannot be obtained
-