File tree 1 file changed +40
-0
lines changed
src/test/java/com/fasterxml/jackson/datatype/joda
1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .fasterxml .jackson .datatype .joda ;
2
+
3
+ import com .fasterxml .jackson .databind .ObjectMapper ;
4
+ import com .fasterxml .jackson .databind .annotation .JsonDeserialize ;
5
+ import com .fasterxml .jackson .databind .annotation .JsonSerialize ;
6
+ import com .fasterxml .jackson .datatype .joda .deser .DateTimeDeserializer ;
7
+ import com .fasterxml .jackson .datatype .joda .ser .DateTimeSerializer ;
8
+ import org .joda .time .DateTime ;
9
+ import org .joda .time .DateTimeZone ;
10
+ import org .junit .Test ;
11
+
12
+ import static org .junit .Assert .assertEquals ;
13
+
14
+
15
+ class AClass {
16
+ @ JsonSerialize (using = DateTimeSerializer .class )
17
+ @ JsonDeserialize (using = DateTimeDeserializer .class )
18
+ private DateTime createdOn = DateTime .now (DateTimeZone .UTC );
19
+
20
+ public DateTime getCreatedOn () {
21
+ return createdOn ;
22
+ }
23
+
24
+ public void setCreatedOn (DateTime createdOn ) {
25
+ this .createdOn = createdOn ;
26
+ }
27
+ }
28
+
29
+ public class AnnotationTest {
30
+
31
+ @ Test
32
+ public void testSomeMethod () throws Exception {
33
+ ObjectMapper objectMapper = new ObjectMapper ();
34
+ AClass initialObject = new AClass ();
35
+ String serializedObject = objectMapper .writeValueAsString (initialObject );
36
+ AClass deserializedObject = objectMapper .readValue (serializedObject , AClass .class );
37
+ assertEquals (deserializedObject .getCreatedOn (), initialObject .getCreatedOn ());
38
+ }
39
+
40
+ }
You can’t perform that action at this time.
0 commit comments