package milo.utils.rest.jaxbadapters;

import javax.xml.bind.annotation.adapters.XmlAdapter;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;

public class ZonedDateTimeToLong extends XmlAdapter<Long, ZonedDateTime> {

	@Override
	public Long marshal(ZonedDateTime timestamp) throws Exception {
		return timestamp.toInstant().toEpochMilli() / 1000;
	}

	@Override
	public ZonedDateTime unmarshal(Long timestamp) throws Exception {
		timestamp *= 1000;
		return ZonedDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault());
	}

}
@@ -371,17 +371,10 @@
 li()
- / 1000
 ;%0A
+
 %09%7D%0A%0A
@@ -455,29 +455,8 @@
 n %7B%0A
-%09%09timestamp *= 1000;%0A
 %09%09re
@@ -546,9 +546,10 @@
 ));%0A%09%7D%0A%0A
-
 %7D
+%0A

fix ZonedDateTime adapter (un)marshaller