I'm trying to create the ISO 8601 formatted DateTime from the Instant
object as per the reference in this article I used the format YYYY-MM-DD'T'hh:mm:ss'T'ZD
to parse the Instant date as below.
But it's generating the time in wrong format:
2022-06-172T06:08:13T-0500172
The expected format should be:
2022-06-21T13:31:49-05:00
My code:
DateTimeFormatter formatter = DateTimeFormatter
.ofPattern("YYYY-MM-DD'T'hh:mm:ss'T'ZD")
.withZone(ZoneId.systemDefault());
formatter.format(Instant.now())
How can I produce the formatted time as shown below?
2022-06-21T13:31:49-05:00