This content has been marked as final.
Show 3 replies
-
1. Re: Resteasy exports dates in textual format on wildfly 14 (Java 11) as opposed to numeric format in wildfly 9 (Java 8)
emeuwese Dec 3, 2018 12:47 PM (in response to gadeyne.bram)In Wildfly 13 with JEE8 enabled, and Wildfly 14 are implementing JSON-P 1.1 and JSON-B 1.0 for json so you could create a provider that implements javax.ws.rs.ext.ContextResolver<javax.json.bind.Jsonb> the set the configuration with a specific date format
-
2. Re: Resteasy exports dates in textual format on wildfly 14 (Java 11) as opposed to numeric format in wildfly 9 (Java 8)
gadeyne.bram Dec 4, 2018 2:25 AM (in response to emeuwese)Thanks Erik,
This works fine!
For those interested. This is my new configuration.
import javax.json.bind.JsonbBuilder; import javax.json.bind.JsonbConfig; import javax.json.bind.annotation.JsonbDateFormat; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.ext.ContextResolver; import javax.ws.rs.ext.Provider; import javax.json.bind.Jsonb; import java.util.logging.Level; import java.util.logging.Logger; @Provider @Produces(MediaType.APPLICATION_JSON) public class JacksonConfig implements ContextResolver { private final Jsonb jsonB; private Logger log; public JacksonConfig() { log = Logger.getLogger(JacksonConfig.class.getName()); log.log(Level.INFO,"Created JacksonConfig"); JsonbConfig config = new JsonbConfig(); config.setProperty(JsonbConfig.DATE_FORMAT, JsonbDateFormat.TIME_IN_MILLIS); jsonB = JsonbBuilder.create(config); } @Override public Jsonb getContext(Class objectType) { log.log(Level.INFO,"Retrieved Objectmapper "+objectType.toGenericString()); return jsonB; } }
-
3. Re: Resteasy exports dates in textual format on wildfly 14 (Java 11) as opposed to numeric format in wildfly 9 (Java 8)
emeuwese Dec 4, 2018 3:49 AM (in response to gadeyne.bram)Thanks, I wrote something similar. I called my class JsonbConfiguration and I would suggest to rename your class because Eclipse Yasson is currently used as implementation for JSON-B so the refference Jackson might be confusing.