我在使用回历日期时遇到错误
错误是:
Invalid Hijrah day of month: 30
代码是:
String date = 13820630;
HijrahDate hDate= HijrahChronology.INSTANCE.date(Integer.valueOf(date.substring(0, 4)),Integer.valueOf(date.substring(4, 6)), Integer.valueOf(date.substring(6, 8)));
有什么想法吗?
谢谢
最佳答案
根据 HijrahDate
类,1372-06 月份只有 29 天。
HijrahDate date = HijrahChronology.INSTANCE.date(1382, 6, 1);
System.out.println(date.lengthOfMonth());
此代码打印 29。
HijrahChronology
的评论说
The Hijrah calendar has several variants based on differences in when the new moon is determined to have occurred and where the observation is made. In some variants the length of each month is computed algorithmically from the astronomical data for the moon and earth and in others the length of the month is determined by an authorized sighting of the new moon. For the algorithmically based calendars the calendar can project into the future. For sighting based calendars only historical data from past sightings is available.
因此,此年表所使用的变体可能与您的预期不同。
关于Java 8 Hijrah 日期错误,当月中的某一天为 30 时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44925353/