samanzamani / PersianDate

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

Wrong date conversion in a specific date #42

Closed MHKalantarian closed 3 years ago

MHKalantarian commented 3 years ago

Date converted to epoch 1360/08/02 > 372780535866 UNIX But when I try to reverse this specific date using new PersianDateFormat("Y/m/d").format(new PersianDate(372780535866 )) it returns 1360/07/01

MHKalantarian commented 3 years ago

This code returns this values and it seems every time a conversion is happening day is getting reduced by 1 Code:

            PersianDate date = new PersianDate();
            date.setShYear(binding.yearNp.getValue());
            date.setShMonth(binding.monthNp.getValue());
            date.setShDay(binding.dayNp.getValue());
            Log.e("Date", binding.yearNp.getValue() + "/" + binding.monthNp.getValue() + "/" + binding.dayNp.getValue());
            Log.e("Date", date.getShYear() + "/" + date.getShMonth() + "/" + date.getShDay());
            Log.e("Date", new PersianDateFormat("Y/m/d").format(new PersianDate(date.getTime())) + " _ " + date.getTime());

Result:

E/Date: 1360/3/8
E/Date: 1360/3/7
E/Date: 1360/03/06 _ 359885553000
samanzamani commented 3 years ago

Bug fixed in v1.0