-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow definition of default DateTimeFormatter
(and date-, time-) for module
#12
Comments
Joda does not support Personally, I would argue for deprecating |
That list of languages/frameworks/servers supporting ISO8601 is not exhaustive. The simple answer is "I have never heard of any language, framework, or database server that did not support ISO8601." |
You might be surprised by number of users who use exotic/eccentric/insane formatting for date values... I do realize challenges in supporting generic facility that is based on
At any rate, I think this would warrant more discussion on user and/or dev lists. |
Maybe a simple solution would be to make JodaModule configurable, let's say pass org.joda.time.format.DateTimeFormat in constructor and then use it for all or specific serializers/deserializers? |
Sounds good to me. Would give more power as well. |
Is the suggest @endryha proposes in a branch anywhere? It seems like it wouldn't be too onerous to implement and is something I could personally use. Would this (and a bump to depend on joda-time 2.2) be enough to promote a new maven release of this project? If it's not in progress, it's likely something I could tackle. |
I have not done changes, but it'd be doable for 2.3 version of the module. Module version is synchronized to core components, so we do build a new one for every update. And right now master branch is for 2.3 (2.3.0-SNAPSHOT), where we can make backwards-incompatible changes and API additions. |
Oh and my not working on this is not related to its merits, but my own workload. So I would be happy to see this get implemented, with simple configurability as suggested. |
…dule - JodaDeserializerBase and JodaSerializerBase gain additional constructor to pass in a joda DateTimeFormatter - JodaModule constructor accepts a DateTimeFormatter, no-args constructor builds one which uses ISODateTimeFormat (should be backwards compat) - JodaTestBase now has a jodaMapper() method which accepts a DateTimeFormatter
I've done an initial cut at this just for DateTime, you can see the diff here: https://github.com/idcmp/jackson-datatype-joda/compare My code settings expand out wildcard imports, if this is a problem I can fix that. If this is generally good, I'll flesh it out for the rest of the data types and create a pull request. |
Any reason this is getting held up? The diff looks very reasonable and it seems to implement exactly the consensus but there's been no movement in a month. |
I didn't see a pull request. @idcmp can you just create a pull request and I can merge that easily, and it would make it in 2.3. |
+1 hope the dateTimeFormat can be configurable |
I resolved other open low-hanging fruits (for 2.3.1): still hoping for a pull request to include in 2.4. Joda-specific formatters should be possible to pass via |
As an alternative/complimentary approach, how about allowing use of the @jsonformat annotation to specify patterns based on Joda DateTimeFormat syntax? |
@pimlottc I like that idea! I think it should be ok, since it should not conflict with other kinds of values (like JDK default Date/Time types). Can anyone think of a downside here? This seems like very much textbook use case for this annotation. |
I'd need configurable date/time/datetime format too. The pull request with the configurable module looks like what I would need, except that there should be 3 instances for formatters : one for time, one for date and one for datetime. |
I see that custom formats are supported for serialization using the @jsonformat pattern parameter. Is there any reason that it is not similarly supported for deserialization? I am having an issue where I want to round-trip an esoteric date format, but it fails in deserialization because of this. |
@eyce9000 No fundamental philosophic reason, just needs to be added in specific handlers. |
We found that replacing the serializer on the module for the appropriate types was sufficient.
|
One additional note for anyone who could help with a patch here: 2.5 has better access to "raw" Pattern value (as String), so it should be quite easy to plug in support. Earlier versions had some minor speed bumps with access. |
DateTimeFormatter
(and date-, time-) for module
Some aspects should now work via "configOverrides" of databind, which allows definition of per-type |
(migrated from http://jira.codehaus.org/browse/JACKSON-422 reported by Paul Carey)
If WRITE_DATES_AS_TIMESTAMPS is false, the serializer in org.codehaus.jackson.map.ser.StdSerializerProvider#defaultSerializeDateValue
writes a string based on the configured formatter
In contrast, the corresponding serializer for Joda dates (org.codehaus.jackson.map.ext.JodaSerializers - DateTimeSerializer#serialize)
simply invokes
The Joda serializer should serialize according to any formatter set on the serialization config.
The text was updated successfully, but these errors were encountered: