使用 Joda 我写:
public static String adjustHijri(String dateHijri, int plusDays) {
// dateHijri formatted as yyyy-MM-dd, eg: 1440-02-30
int yearHijri = Integer.parseInt(dateHijri.substring(0, 4));
int monthHijri = Integer.parseInt(dateHijri.substring(5, 7));
int dayHijri = Integer.parseInt(dateHijri.substring(8));
DateTime date = new DateTime(yearHijri, monthHijri, dayHijri, 0, 0, IslamicChronology.getInstance());
return date.plusDays(plusDays).toString("yyyy-MM-dd");
}
对于 dateHijri=1440-02-30 我得到:
org.joda.time.IllegalFieldValueException: Value 30 for dayOfMonth must be in the range [1,29]