While converting from String to LocalDateTime StringIndexOutOfBoundsException occured.
String date = "2020-10-20 04:51:54";
LocalDateTime dateTime = this.convertToLocalDate(date);
public LocalDateTime convertToLocalDate(String datStr) {
if ( datStr != null ) {
datStr = (String) datStr.subSequence(0, datStr.lastIndexOf("+"));
} else {
return LocalDateTime.now();
}
return LocalDateTime.parse(datStr, dateFormatter);
}
Getting Indexof as -1.
Your string declared as date does not contain a plus sign.
The java documentation says following for the return value of String.lastIndex: