I have the following code:
try {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMM dd yyyy HH:mm:ss 'GMT'xxx");
logger.debug("formatter: " + formatter);
ZonedDateTime zdt = ZonedDateTime.parse(rtime, formatter);
} catch (DateTimeParseException e) {
if (logger.isDebugEnabled()) {
logger.debug("Failed to parse device time [" + rtime + "] ", e);
}
}
rtime
here is Jan 17 2019 03:38:06 GMT+00:00
Debug is printing out
formatter: Text(MonthOfYear,SHORT)' 'Value(DayOfMonth,2)' 'Value(YearOfEra,4,19,EXCEEDS_PAD)' 'Value(HourOfDay,2)':'Value(MinuteOfHour,2)':'Value(SecondOfMinute,2)' ''GMT'Offset(+HH:MM,'+00:00')`
The error is :
Failed to parse device time [Jan 17 2019 03:38:06 GMT+00:00]
java.text.ParseException: Unparseable date: "Jan 17 2019 03:38:06 GMT+00:00"
I tried a few patterns and it is always failing.
Could someone help?