Revision 50985
Added by Claudio Atzori about 6 years ago
Event.java | ||
---|---|---|
4 | 4 |
import java.util.Map; |
5 | 5 |
|
6 | 6 |
import com.google.gson.Gson; |
7 |
import com.google.gson.GsonBuilder; |
|
7 | 8 |
|
8 | 9 |
public class Event { |
9 | 10 |
|
11 |
public static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; |
|
12 |
|
|
10 | 13 |
private String eventId; |
11 | 14 |
|
12 | 15 |
private String producerId; |
... | ... | |
103 | 106 |
} |
104 | 107 |
|
105 | 108 |
public String toJson() { |
106 |
return new Gson().toJson(this); |
|
109 |
|
|
110 |
final Gson gson = new GsonBuilder() |
|
111 |
.setDateFormat(DATE_FORMAT).create(); |
|
112 |
|
|
113 |
return gson.toJson(this); |
|
107 | 114 |
} |
108 | 115 |
} |
Also available in: Unified diff
force gson to serialise dates in a format that can be undrestood by ElasticSearch