我已经尝试了几乎所有关于这个片段的方法,但我仍然得到 IllegalInstentException。
public int getDateDay() {
DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd");
DateTime dt;
try {
dt = formatter.parseDateTime(date);
} catch (IllegalInstantException e) {
dt = formatter.parseLocalDateTime(date).toDateTime();
}
return dt.getDayOfMonth();
}
致命异常:org.joda.time.IllegalInstantException 由于时区偏移转换(夏令时“间隙”)导致的非法即时:2018-10-21T00:00:00.000 (America/Sao_Paulo) keyboard_arrow_up arrow_right org.joda.time.chrono .ZonedChronology.localToUTC (ZonedChronology.java:157) org.joda.time.chrono.ZonedChronology.getDateTimeMillis (ZonedChronology.java:122) org.joda.time.chrono.AssembledChronology.getDateTimeMillis (AssembledChronology.java:133) org.joda .time.base.BaseDateTime。(BaseDateTime.java:257) org.joda.time.DateTime。(DateTime.java:532) org.joda.time.LocalDateTime.toDateTime (LocalDateTime.java:750) org.joda.time.LocalDateTime.toDateTime (LocalDateTime.java:731)