|
20 | 20 |
|
21 | 21 | import java.text.ParsePosition; |
22 | 22 | import java.text.SimpleDateFormat; |
| 23 | +import java.util.Date; |
23 | 24 | import java.util.GregorianCalendar; |
24 | 25 | import java.util.SimpleTimeZone; |
25 | 26 | import java.util.UUID; |
@@ -76,13 +77,21 @@ public Object objectDone(){ |
76 | 77 | new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); |
77 | 78 | GregorianCalendar calendar = new GregorianCalendar(new SimpleTimeZone(0, "GMT")); |
78 | 79 | format.setCalendar(calendar); |
79 | | - String txtdate = (String) b.get("$date"); |
80 | | - o = format.parse(txtdate, new ParsePosition(0)); |
81 | | - if (o == null) { |
82 | | - // try older format with no ms |
83 | | - format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); |
84 | | - format.setCalendar(calendar); |
| 80 | + |
| 81 | + String txtdate = b.get("$date").toString(); |
| 82 | + |
| 83 | + try { |
| 84 | + // Convert from seconds to ms to match consistency |
| 85 | + // with strict JSON serialization |
| 86 | + o = new Date( Long.parseLong(txtdate) * 1000l); |
| 87 | + } catch (NumberFormatException e) { |
85 | 88 | o = format.parse(txtdate, new ParsePosition(0)); |
| 89 | + if (o == null) { |
| 90 | + // try older format with no ms |
| 91 | + format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); |
| 92 | + format.setCalendar(calendar); |
| 93 | + o = format.parse(txtdate, new ParsePosition(0)); |
| 94 | + } |
86 | 95 | } |
87 | 96 | if (!isStackEmpty()) { |
88 | 97 | cur().put( name, o ); |
|
0 commit comments