You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After #219 was fixed, the default format for java.sql.Date serialization switched from string to numeric, following the default value of WRITE_DATES_AS_TIMESTAMPS.
In order to prevent breaks, I want java.sql.Date to serialize as a string, without changing behavior for java.util.Date (which has always serialized as a number by default).
According to #219 (comment), I should be able to revert the behavior for java.sql.Date only with
final ObjectMapper mapper = new ObjectMapper();
mapper.configOverride(java.sql.Date.class).setFormat(JsonFormat.Value.forPattern("yyyy-MM-dd"));
Quick note: timing here is bit unfortunate, as I just released 2.9.6. But of course, with fixes, better late than never. :)
Thank you for reporting the issue.
cowtowncoder
changed the title
Cannot set custom format for SqlDateSerializer globally
Cannot set custom format for SqlDateSerializer globally
Aug 31, 2018
Version: 2.9.5
After #219 was fixed, the default format for
java.sql.Date
serialization switched from string to numeric, following the default value ofWRITE_DATES_AS_TIMESTAMPS
.In order to prevent breaks, I want
java.sql.Date
to serialize as a string, without changing behavior forjava.util.Date
(which has always serialized as a number by default).According to #219 (comment), I should be able to revert the behavior for
java.sql.Date
only withThis doesn't seem to do anything, though. Looking at the code, it looks like it's because the custom format isn't actually added to
SqlDateSerializer
except in thecreateContextual
method (https://github.com/FasterXML/jackson-databind/blob/master/src/main/java/com/fasterxml/jackson/databind/ser/std/DateTimeSerializerBase.java#L59).For now, I've reverted this behavior with
but it seems pretty hacky so I'd prefer the other method if possible.
The text was updated successfully, but these errors were encountered: