Package com.github.mfathi91.time
Enum PersianMonth
java.lang.Object
java.lang.Enum<PersianMonth>
com.github.mfathi91.time.PersianMonth
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<PersianMonth>,java.lang.constant.Constable
@Immutable public enum PersianMonth extends java.lang.Enum<PersianMonth>
A month-of-year, such as Mehr.
PersianMonth is an enum representing the 12 months of the year
Farvardin, Ordibehesht, Khordad, Tir, Mordad, Shahrivar, Mehr, Aban, Azar, Dey,
Bahman and Esfand.
In addition to the textual enum name, each month-of-year has an int value.
The int value follows normal usage and the ISO-8601 standard,
from 1 (January) to 12 (December). It is recommended that applications use the enum
rather than the int value to ensure code clarity.
Do not use ordinal() to obtain the numeric representation of Month.
Use getValue() instead.
This is an immutable enum and can be used in concurrent programs.
- Author:
- Mahmoud Fathi
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
java.lang.Enum.EnumDesc<E extends java.lang.Enum<E>> -
Enum Constant Summary
Enum Constants Enum Constant Description ABANThe singleton instance for the month of Aban with 30 days.AZARThe singleton instance for the month of Azar with 30 days.BAHMANThe singleton instance for the month of Bahman with 30 days.DEYThe singleton instance for the month of Dey with 30 days.ESFANDThe singleton instance for the month of Farvardin with 29 days in non-leap year and 30 days in leap year.FARVARDINThe singleton instance for the month of Farvardin with 31 days.KHORDADThe singleton instance for the month of Khordad with 31 days.MEHRThe singleton instance for the month of Mehr with 30 days.MORDADThe singleton instance for the month of Mordad with 31 days.ORDIBEHESHTThe singleton instance for the month of Ordibehesht with 31 days.SHAHRIVARThe singleton instance for the month of Shahrivar with 31 days.TIRThe singleton instance for the month of Tir with 31 days. -
Method Summary
Modifier and Type Method Description intdaysToFirstOfMonth()Returns elapsed days from first of the year to first of this month.java.lang.StringgetPersianName()Returns name of month in persian alphabe.intgetValue()intlength(boolean leapYear)Returns length of month.intmaxLength()Returns length of month in a leap year.intminLength()Returns length of month in a non-leap year.PersianMonthminus(long months)Returns a month-of-year that ismonthsbefore current month.PersianMonthplus(long months)Returns a month-of-year that ismonthsafter current month.static PersianMonthvalueOf(java.lang.String name)Returns the enum constant of this type with the specified name.static PersianMonth[]values()Returns an array containing the constants of this enum type, in the order they are declared.Methods inherited from class java.lang.Enum
clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOfMethods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
-
Enum Constant Details
-
FARVARDIN
The singleton instance for the month of Farvardin with 31 days. This has the numeric value of1. -
ORDIBEHESHT
The singleton instance for the month of Ordibehesht with 31 days. This has the numeric value of2. -
KHORDAD
The singleton instance for the month of Khordad with 31 days. This has the numeric value of3. -
TIR
The singleton instance for the month of Tir with 31 days. This has the numeric value of4. -
MORDAD
The singleton instance for the month of Mordad with 31 days. This has the numeric value of5. -
SHAHRIVAR
The singleton instance for the month of Shahrivar with 31 days. This has the numeric value of6. -
MEHR
The singleton instance for the month of Mehr with 30 days. This has the numeric value of7. -
ABAN
The singleton instance for the month of Aban with 30 days. This has the numeric value of8. -
AZAR
The singleton instance for the month of Azar with 30 days. This has the numeric value of9. -
DEY
The singleton instance for the month of Dey with 30 days. This has the numeric value of10. -
BAHMAN
The singleton instance for the month of Bahman with 30 days. This has the numeric value of11. -
ESFAND
The singleton instance for the month of Farvardin with 29 days in non-leap year and 30 days in leap year. This has the numeric value of12.
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException- if this enum type has no constant with the specified namejava.lang.NullPointerException- if the argument is null
-
getPersianName
public java.lang.String getPersianName()Returns name of month in persian alphabe.- Returns:
- persian name of month.
-
getValue
public int getValue()- Returns:
- number of month, from 1 (Farvardin) to 12 (Esfand)
-
length
public int length(boolean leapYear)Returns length of month. For the first six months of year,31is returned. For the second six months of year except Esfand,30is returned. Finlally For Esfand, ifleapYearis true, it returns30, otherwise it returns29.- Parameters:
leapYear- true, if length of months in leap year is required- Returns:
- length of months of Persian calendar
-
maxLength
public int maxLength()Returns length of month in a leap year. For the first six months of year,31is returned. For the second six months of year30is returned.- Returns:
- length of months of Persian calendar
-
minLength
public int minLength()Returns length of month in a non-leap year. For the first six months of year,31is returned. For the second six months of year except Esfand,30is returned. For Esfand29is returned.- Returns:
- length of months of Persian calendar
-
plus
Returns a month-of-year that ismonthsafter current month. The calculation rolls around end of year from Esfand to Farvardin.This enum is immutable and unaffected by calling this method.
- Parameters:
months- the months to add, positive or negative- Returns:
- the resulting month, not null
-
minus
Returns a month-of-year that ismonthsbefore current month. The calculation rolls around the start of year from Farvardin to Esfand.This enum is immutable and unaffected by calling this method.
- Parameters:
months- the months to subtract, positive or negative- Returns:
- the resulting month, not null
-
daysToFirstOfMonth
public int daysToFirstOfMonth()Returns elapsed days from first of the year to first of this month.- Returns:
- elapsed days from first of the year to first of this month.
-