public static String elasticSearchTimeFormatToISO8601 ( String time ) { try { DateTime dt = DateTime . parse ( time , ES_DATE_FORMAT_FORMATTER ) ; return getISO8601String ( dt ) ; } catch ( IllegalArgumentException e ) { return time ; } }
Try to parse a date in ES_DATE_FORMAT format considering it is in UTC and convert it to an ISO8601 date . If an error is encountered in the process it will return the original string .