Guest User

Untitled

a guest
Dec 14th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. "date": {
  2. "type": "date",
  3. "format": "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
  4. }
  5.  
  6. client.prepareIndex(INDEX, TYPE, id))
  7. .setSource(gson.toJson(object), XContentType.JSON)
  8. .setRefreshPolicy(RefreshPolicy.IMMEDIATE)
  9. .get();
  10.  
  11. public class ZonedDateTimeAdapter implements JsonSerializer<ZonedDateTime> {
  12.  
  13. public JsonElement serialize(ZonedDateTime date, Type typeOfSrc, JsonSerializationContext context) {
  14. DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
  15. return new JsonPrimitive(date.format(formatter));
  16. }
  17.  
  18. }
Add Comment
Please, Sign In to add comment