I've tried almost everything about this snippet, and I still get 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();
}
Fatal Exception: org.joda.time.IllegalInstantException Illegal instant due to time zone offset transition (daylight savings time 'gap'): 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)
Seems the input is not a valid date. The problem has been discussed in this page.
Reason:
Possible solutions may be as follows: