As per the requirement, my code is supposed to append date from a ZonedDateTime parameter, and Time from OffSetTime parameter into this format, "yyyy-MM-dd HH:mm:ss.SSSz". However, i was not been able to achieve this
I have tried various ways , including the one below, using DateTimeFormatter.
ZonedDateTime zonedDateTime = ZonedDateTime.parse("2019-05-23T09:00:00-05:00");
OffsetTime offsetTime = OffsetTime.parse("08:59:00-05:00");
LocalDateTime localDateTime = LocalDateTime.of(zonedDateTime.toLocalDate(), offsetTime.toLocalTime());
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSz");
String finalDate = localDateTime.format(formatter);
I notice that : - code is throwing "java.time.DateTimeException: Unable to extract value: class java.time.LocalDateTime" at localDateTime.format(formatter)
The expectation is to get the DateTime in String like so - "2019-05-23T08:59:00.000Z"
Any help appreciated, Thank you for your time.