I have tried below tests. But unable to parse the date format: 2020-04-19T19:00:54
why am I facing this issue?
public ZonedDateTime convert(Utf8 date) {
String datee = ((String) date.toString()).replace("T", " ")
LocalDateTime today = LocalDateTime.parse(datee, formatter)
ZonedDateTime currentISTime = today.atZone(ZoneId.systemDefault())
ZonedDateTime currentETime = currentISTime.withZoneSameInstant(ZoneId.systemDefault())
return ZonedDateTime.parse(formatter.format(currentETime), formatter)
}
String datee = ((String) date.toString()).replace("T", " ")
try{
var zoned = ZonedDateTime.from(DateTimeFormatter.ISO_DATE_TIME.parse(datee.toString()))
return zoned.withZoneSameInstant(ZoneId.systemDefault())
} catch (DateTimeException e) {
//no time zone information -> parse as LocalDate
return ZonedDateTime.parse(datee.toString())
}
Exception:
Exception in thread "main" java.time.format.DateTimeParseException: Text '2020-04-19 19:00:54' could not be parsed at index 10 at java.base/java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:2046)
at java.base/java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1948)
at java.base/java.time.ZonedDateTime.parse(ZonedDateTime.java:598)
at java.base/java.time.ZonedDateTime.parse(ZonedDateTime.java:583)