Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "date": {
- "type": "date",
- "format": "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
- }
- client.prepareIndex(INDEX, TYPE, id))
- .setSource(gson.toJson(object), XContentType.JSON)
- .setRefreshPolicy(RefreshPolicy.IMMEDIATE)
- .get();
- public class ZonedDateTimeAdapter implements JsonSerializer<ZonedDateTime> {
- public JsonElement serialize(ZonedDateTime date, Type typeOfSrc, JsonSerializationContext context) {
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
- return new JsonPrimitive(date.format(formatter));
- }
- }
Add Comment
Please, Sign In to add comment