How to convert timestamp string to epoch time?
问题 I have time stamp in format 2017-18-08 11:45:30.345 . I want to convert it to epoch time, so I am doing below: String timeDateStr = "2017-18-08 11:45:30.345"; DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-dd-MM HH:mm:ss.SSS"); ZonedDateTime zdt = ZonedDateTime.parse(timeDateStr, dtf); System.out.println(zdt.toInstant().toEpochMilli()); I am getting below error: java.time.format.DateTimeParseException: Text '2017-18-08 11:45:30.345' could not be parsed: Unable to obtain