Java 8 Hijrah 日期错误,当月中的某一天为 30 时

标签 java

我在使用回历日期时遇到错误

错误是:

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.

因此,此年表所使用的变体可能与您的预期不同。

其他变体可通过Chronology.getAvailableChronologies()获得

关于Java 8 Hijrah 日期错误,当月中的某一天为 30 时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44925353/

相关文章:

java - 从Weblogic 10.3.6升级到12.1.3

代表PNG图像的Java类型?

java - 单击另一个按钮时永久启用一个按钮。即使应用程序重新启动

java - Jersey + HK2 : EntityManager injection fails

java - for 循环如何检查其在 Java 中的条件?

java - Android LoaderManager 已弃用。怎么办?

java - 在 Android 1.5 中删除短信

java - (JNI) 使用GetMethodID获取Java方法的内存地址

java - 如何仅延迟特定方法?

java - toDerInputStream 拒绝标记类型 0 - 无法从 keystore 中读取 key