samanzamani / PersianDate

Persian date for android
BSD 3-Clause "New" or "Revised" License
328 stars 40 forks source link

End of month issue #36

Closed fardinfrd closed 3 years ago

fardinfrd commented 3 years ago

Hi Saman

Suppos current date is end of month, for example 30 Mehr 1399, when I call PersianDate constructor and set date to 1398/12/29 the result date has wrong result

PersianDate persianDate = new PersianDate(); // result is current date, such as 1399/07/30
persianDate.setShYear(1398); // 1398/07/30
persianDate.setShMonth(12); // 1398/12/30 -> 1399/01/01
persianDate.setShDay(29); // 1399/01/29
persianDate.getTime() // 1399/01/29 != 1398/12/29

It seems to need another constructor. (PersianDate(year, month, day))

thanks

samanzamani commented 3 years ago

Hi @fardinfrd I was chacked methods but it worked currectly.

PersianDate persianDate = new PersianDate(); // result is current date, such as 1399/07/30
persianDate.setShYear(1398)
    .setShMonth(12)
    .setShDay(29);
Log.i("LOG","Date is" + PersianDateFormat.format(persianDate,null)); //return پنج‌شنبه 29 اسفند 1398

Although there is a method called initJalaliDate for initiation date with year, month, and day. Let me know if you have any problems.