I have some Java code which returns the ISO-8601 time format from a given epoch time.
public String getISO8601(String epochTime) {
long epoch = Long.parseLong(epochTs);
ZoneId zone = ZoneId.of("Europe/London");
LocalDate then = Instant.ofEpochMilli(epoch).atZone(zone).toLocalDate();
LocalDate today = LocalDate.now(zone);
Period diff = Period.between(then, today);
return diff.toString();
}
When I pass epochTime to it: 1512259200000
This epoch time is: Sun 2017-12-03 00:00:00
So the method getISO8601 will return: P1Y
This is great! But is there any way I can make sure it will always and only return in days... for example: P365D (instead of: P1Y)