Convert string '2018-08-27T16:40:02+08:00'
to datetime using DateTimeFormatter
private static final String DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss";
String rawDateString = "2018-08-27T16:40:02+08:00"
DateTimeFormatter dateTimeFormatter =
DateTimeFormatter.ofPattern(DATE_TIME_FORMAT, Locale.ENGLISH);
LocalDateTime localDateTime = LocalDateTime.parse(rawDateString, dateTimeFormatter);
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
but this returns DateTimeParseException: Text could not be parsed at index 19
I saw some similar issue like this
DateTimeParseException: Text could not be parsed at index 2
but I dont see any sample with timezone on datetime format.