[JAVA-1299] Support JSR-310 Dates Created: 01/Jul/14 Updated: 10/Jan/23 Resolved: 08/Mar/18 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Codecs |
| Affects Version/s: | None |
| Fix Version/s: | 3.7.0 |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Fabian Lange [X] | Assignee: | Ross Lawley |
| Resolution: | Done | Votes: | 4 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Description |
|
The current version of the Java driver only accepts java.util.Date for reading and writing Dates. While you could work with them already now, it would always require the creation of temporary java.util.Date objects, either bei the driver when reading, or by the developer when writing. The driver should be configurable that joda-time or JSR 310 is directly used. Or that as a Developer I can at least provide a converter to do so (and especially avoid java.util.Date inbetween) |
| Comments |
| Comment by Asaf Chelouche [ 26/Jun/18 ] |
|
I'm experiencing weird behavior with driver v3.7.0: without any special configuration I'm able to use java.time.Instant when constructing search filters using org.bson.Document, however when I try to generate a JSON string from the search filter via Document::toJson, a CodecConfigurationException is thrown with the cause "Can't find a codec for class java.time.Instant". I could not find any supporting resource online that would explain this weird behavior, where in one place a usage of Instant works and in another place it crashes. |
| Comment by Ross Lawley [ 08/Mar/18 ] |
|
cbartosiak, many thanks for your help and contributions to the driver. Users wanting alternative data structures and / or more flexibility regarding JSR-310 dates should check out the alternative JSR-310 codecs provider by cbartosiak: bson-codecs-jsr310. |
| Comment by Githook User [ 08/Mar/18 ] |
|
Author: {'email': 'ross.lawley@gmail.com', 'name': 'Ross Lawley', 'username': 'rozza'}Message: JSR-310 Instant & LocalDate/Time support
|
| Comment by Ross Lawley [ 14/Feb/18 ] |
| Comment by Ross Lawley [ 13/Feb/18 ] |
|
Hi cbartosiak, Thanks for the offer, I'll send you an email directly. Ross |
| Comment by Cezary Bartosiak [ 12/Feb/18 ] |
|
Hi again, I would like to contribute with the codecs I've written, but I've stumbled on a question how to integrate JDK 8 API based code with the current codebase which should support a minimum version of Java 6. Hence these codecs cannot be a part of the default codec registry and should be injected conditionally. Do you have a best practice for this kind of problem? |
| Comment by Cezary Bartosiak [ 28/Dec/17 ] |
|
Hi, Is there any code ready for this feature? If not I'm eager to contribute with the library I've written. |
| Comment by Andrew Harris [ 08/Dec/17 ] |
|
Awesome |
| Comment by Ross Lawley [ 01/Jul/14 ] |
|
Hi CodingFabian, This is on the roadmap and something that will be easy to do with the new codecs implementation on the 3.0.x branch. The final implementation is still being hammered out but there will be no need for an intermediate java.util.Date. I'll keep this ticket open and once the api is finalised I'll post a code example here. Ross |