I try to create a pattern to parse the date / time of Apache Access Log-a. Example
'30/Nov/2016:04:13:36 +0200' I set the pattern
private DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MMM/yyyy:HH:mm:ss Z"); As a result, I get an exception when using the parse method:
Exception in thread "AWT-EventQueue-0" java.time.format.DateTimeParseException: Text '30/Nov/2016:04:13:36 +0200' could not be parsed at index 3 How to set the pattern for DateTimeFormatter correctly? It seems to be doing everything according to the documentation, and still something is not right.
Edit: For template
formatter = DateTimeFormatter.ofPattern("dd/MMM/yyyy:hh:mm:ss Z"); String datetime = "30/Nov/2016:04:13:36 +0200"; ZonedDateTime zonedDateTime = ZonedDateTime.parse(datetime, formatter); Gives exactly the same exception.
Exception in thread "AWT-EventQueue-0" java.time.format.DateTimeParseException: Text '30/Nov/2016:04:13:36 +0200' could not be parsed at index 3