scylla-apiclient: Add Date json serializer helper

To handle RFC8601 formattedd dates in JAXB
This commit is contained in:
Calle Wilund 2019-07-24 14:30:02 +00:00
parent d8efa60ab7
commit b2f3eeee05

View File

@ -0,0 +1,19 @@
package com.scylladb.jmx.utils;
import java.time.Instant;
import java.util.Date;
import javax.xml.bind.annotation.adapters.XmlAdapter;
public class DateXmlAdapter extends XmlAdapter<String, Date> {
@Override
public String marshal(Date v) throws Exception {
return Instant.ofEpochMilli(v.getTime()).toString();
}
@Override
public Date unmarshal(String v) throws Exception {
return new Date(Instant.parse(v).toEpochMilli());
}
}