How can I parse this timestamp
1594361788215
to data in String type in this format 2020-10-26T15:21:47.758+01:00
How can I parse this timestamp
1594361788215
to data in String type in this format 2020-10-26T15:21:47.758+01:00
You can easily format an epoch timestamp to a string with the library java.time
.
First, you'll have to convert the epoch timestamp you have into a ZonedDateTime:
ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(
Instant.ofEpochMilli(1594361788215L),
ZoneId.of("Europe/London"));
And the format you described corresponds to ISO_OFFSET_DATE_TIME
String formatted = zonedDateTime.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME);