[JAVA-395] Date Time values do not preserve milliseconds when serialized to or deserialized from JSON Created: 15/Jul/11 Updated: 10/Aug/11 Resolved: 19/Jul/11 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | None |
| Affects Version/s: | 2.6.2, 2.6.3 |
| Fix Version/s: | 2.6.4 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | jgro | Assignee: | Antoine Girbal |
| Resolution: | Done | Votes: | 0 |
| Labels: | bson | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Mongo and BSON Date types store time with millisecond precision. Java's java.util.Date class does too. However, com.mongodb.util.JSON.serialize() outputs Date strings without milliseconds using SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'") and com.mongodb.util.JSON.parse() does not accept date strings containing milliseconds. This leads to Date date = new Date(); to print "Dates are equal? false" Date format should instead be SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"). Currently, JSON.parse() does not accept time strings that include milliseconds, returning null instead of a Date object. It should accept strings with milliseconds, and maintain backwards compatibility (for people who have stored JSON strings somewhere) by continuing to accept strings without milliseconds. |
| Comments |
| Comment by auto [ 19/Jul/11 ] |
|
Author: {u'login': u'agirbal', u'name': u'agirbal', u'email': u'antoine@10gen.com'}Message: - |