I use the following code to get the date in ISO-8601 format. For UTC, the return value does not contain an offset.
OffsetDateTime dateTime = OffsetDateTime.ofInstant( Instant.ofEpochMilli(epochInMilliSec), zoneId); return dateTime.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME);
For other time formats, the response returned looks like this:
2016-10-30T17: 00: 00-07: 00
In case of UTC, the return value is:
2016-10-30T17: 00: 00Z
I want this to be:
2016-10-30T17: 00: 00 + 00: 00
Note. Do not use UTC-0, since -00: 00 does not comply with ISO8601.
java datetime java-time datetime-format
Priya Jain Jul 27 '17 at 11:56 on 2017-07-27 11:56
source share