How to handle jodatime Illegal instant due to time zone offset transition


This is what I did to resolve. Use UTC TimeZone to resolve these type of issues.

DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss").withZone(DateTimeZone.UTC);
DateTime dateTimeUTC = new DateTime(formatter.parseDateTime(dateString));
Long epocTime = dateTimeUTC.getMillis();

Always store epocTime in database rather than storing the Date values.

No comments:

 Python Basics How to check the version of Python interpreter mac terminal

Popular in last 30 days