scylla-apiclient: Add Date json serializer helper
To handle RFC8601 formattedd dates in JAXB
This commit is contained in:
parent
d8efa60ab7
commit
b2f3eeee05
19
src/main/java/com/scylladb/jmx/utils/DateXmlAdapter.java
Normal file
19
src/main/java/com/scylladb/jmx/utils/DateXmlAdapter.java
Normal 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());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user