public class DateConverter extends Object
This class is a main class of jeloy calendar as it converts jalali to gregorian and gregorian to jalali. In order to handel gregorian's date it uses java8's LocalDate, for converted jalali date it uses JalaliDate class which is a class that holds attributes of specific jalali date.
LocalDate,
JalaliDate| Constructor and Description |
|---|
DateConverter() |
| Modifier and Type | Method and Description |
|---|---|
protected DayOfWeekPersian |
getDayOfWeekPersian(JalaliDate jalaliDate) |
JalaliDate |
gregorianToJalali(int year,
int month,
int day)
converts gregorian date based on input arguments to jalali date.
|
JalaliDate |
gregorianToJalali(int year,
java.time.Month month,
int day)
converts gregorian date based on input arguments to jalali date.
|
java.time.LocalDate |
jalaliToGregorian(int year,
int month,
int day)
converts jalali date based on input arguments to gregorian date.
|
java.time.LocalDate |
jalaliToGregorian(int year,
MonthPersian month,
int day)
converts jalali date based on input arguments to gregorian date.
|
java.time.LocalDate |
jalaliToGregorian(JalaliDate jalaliDate)
converts jalali date based on input arguments to gregorian date.
|
protected boolean |
leapPersiana(double year)
checks whether provided year is leap year or not.
|
java.time.LocalDate |
nowAsGregorian()
returns current gregorian date based on Java8's LocalDate.
|
JalaliDate |
nowAsJalali()
returns current date based on jalali Date.
|
public java.time.LocalDate jalaliToGregorian(JalaliDate jalaliDate)
jalaliDate - will be converted to suitable form of gregorian date.LocalDate version of gregorian date will be returned.public java.time.LocalDate jalaliToGregorian(int year,
MonthPersian month,
int day)
year - positive jalali year valuemonth - is jeloy's MonthPersian which is similar to java8's Monthday - positive jalali day, it can be more than 31 and automatically it tries to shift to next monthLocalDate version of gregorian date will be returned.IllegalArgumentException - if values are negative.public java.time.LocalDate jalaliToGregorian(int year,
int month,
int day)
It's smart enough to calculate target date with every input so instead of month from 1 to 12 it's possible to enter 13 in this case it automatically shift to next year, it works for days in a same way. although, for your own comfort it is recommended to use proper values
year - positive jalali year valuemonth - starts from 1 to 12, but it can be more than 12 as it tires to shift to next yearday - positive jalali day, it can be more than 31 and automatically it tries to shift to next monthIllegalArgumentException - if values are negative.JalaliDatepublic JalaliDate gregorianToJalali(int year, int month, int day)
year - gregorian positive yearmonth - starts from 1 to 12, but it can be more than 12 as it tires to shift to next yearday - positive gregorian day, it can be more than 31 and automatically it tries to shift to next monthIllegalArgumentException - if values are negative.JalaliDateprotected DayOfWeekPersian getDayOfWeekPersian(JalaliDate jalaliDate)
public JalaliDate gregorianToJalali(int year, java.time.Month month, int day)
year - gregorian positive yearmonth - is Java8's Month objectday - positive gregorian day, it can be more than 31 and automatically it tries to shift to next monthIllegalArgumentException - if values are negative.JalaliDatepublic JalaliDate nowAsJalali()
This method works based on LocalDate, it first gets current date of os-system as
gregorian and then casts it to Jalali.
JalaliDatepublic java.time.LocalDate nowAsGregorian()
This method created just for convenient, of-course it is possible to directly use LocalDate class.
LocalDateprotected boolean leapPersiana(double year)
This method should not be used by other classes or methods outside of this package.
year - positive jalali yearCopyright © 2018. All rights reserved.