File tree Expand file tree Collapse file tree 3 files changed +15
-0
lines changed
main/java/com/arangodb/velocypack
test/java/com/arangodb/velocypack Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Original file line number Diff line number Diff line change 1
1
v4.1.2 (2016-11-xx)
2
2
---------------------------
3
3
* fixed GraphEntity for ArangoDatabase.getGraphs() (field name is null)
4
+ * added VelocyPack UTC_DATE parsing to Json String (ISO 8601)
4
5
5
6
v4.1.1 (2016-11-09)
6
7
---------------------------
Original file line number Diff line number Diff line change 21
21
package com .arangodb .velocypack ;
22
22
23
23
import java .io .IOException ;
24
+ import java .text .DateFormat ;
25
+ import java .text .SimpleDateFormat ;
24
26
import java .util .HashMap ;
25
27
import java .util .Iterator ;
26
28
import java .util .Map ;
40
42
*/
41
43
public class VPackParser {
42
44
45
+ private static final DateFormat DATE_FORMAT = new SimpleDateFormat ("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" );// ISO 8601
43
46
private static final char OBJECT_OPEN = '{' ;
44
47
private static final char OBJECT_CLOSE = '}' ;
45
48
private static final char ARRAY_OPEN = '[' ;
@@ -122,6 +125,8 @@ private void parse(
122
125
json .append (JSONValue .toJSONString (value .getAsString ()));
123
126
} else if (value .isNumber ()) {
124
127
json .append (value .getAsNumber ());
128
+ } else if (value .isDate ()) {
129
+ json .append (JSONValue .toJSONString (DATE_FORMAT .format (value .getAsDate ())));
125
130
} else if (value .isNull ()) {
126
131
json .append (NULL );
127
132
} else {
Original file line number Diff line number Diff line change 23
23
import static org .hamcrest .Matchers .is ;
24
24
import static org .junit .Assert .assertThat ;
25
25
26
+ import java .util .Date ;
27
+
26
28
import org .json .simple .JSONValue ;
27
29
import org .junit .Test ;
28
30
@@ -445,4 +447,11 @@ public void deserialize(
445
447
assertThat (json , is ("{\" a\" :\" a1\" ,\" b\" :\" b\" }" ));
446
448
}
447
449
450
+ @ Test
451
+ public void dateToJson () {
452
+ final VPackSlice vpack = new VPackBuilder ().add (new Date (1478766992059L )).slice ();
453
+ final VPackParser parser = new VPackParser ();
454
+ assertThat (parser .toJson (vpack ), is ("\" 2016-11-10T09:36:32.059Z\" " ));
455
+ }
456
+
448
457
}
You can’t perform that action at this time.
0 commit comments