We are using CXF in combination with Jackson (JacksonJaxbJsonProvider) to marshall domain objects into JSON. Everything is working good, with the exception that I cannot get dates to format the way I want them to. In short, what I want, is to output dates as seconds since epoch (also called unix time). This is partly doable with SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS
, but this gives me milliseconds, not seconds. As my dates don't have such high precision (and never will), I am wasting 4 bytes for every timestamp.
To my knowledge, the only way I can control the date format is by using setDateFormat()
on ObjectMapper
. This function accepts a DateFormat
. However, it does not seem like a DateFormat
can output seconds since epoch, only milliseconds.
Are there any other ways of doing this?