diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/util/xcontent/builder/XContentBuilder.java b/modules/elasticsearch/src/main/java/org/elasticsearch/util/xcontent/builder/XContentBuilder.java index 2e2f7feffd1..39071c115e4 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/util/xcontent/builder/XContentBuilder.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/util/xcontent/builder/XContentBuilder.java @@ -52,7 +52,7 @@ public abstract class XContentBuilder { CAMELCASE } - private final static DateTimeFormatter defaultDatePrinter = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC); + public final static DateTimeFormatter defaultDatePrinter = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC); protected static FieldCaseConversion globalFieldCaseConversion = FieldCaseConversion.NONE; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/util/xcontent/support/XContentMapConverter.java b/modules/elasticsearch/src/main/java/org/elasticsearch/util/xcontent/support/XContentMapConverter.java index 56916badf9a..ac6864cad73 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/util/xcontent/support/XContentMapConverter.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/util/xcontent/support/XContentMapConverter.java @@ -21,12 +21,10 @@ package org.elasticsearch.util.xcontent.support; import org.elasticsearch.util.xcontent.XContentGenerator; import org.elasticsearch.util.xcontent.XContentParser; +import org.elasticsearch.util.xcontent.builder.XContentBuilder; import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * @author kimchy (shay.banon) @@ -143,6 +141,10 @@ public class XContentMapConverter { writeObjectArray(gen, (Object[]) value); } else if (type == byte[].class) { gen.writeBinary((byte[]) value); + } else if (type == Date.class) { + gen.writeString(XContentBuilder.defaultDatePrinter.print(((Date) value).getTime())); + } else if (type == java.sql.Date.class) { + gen.writeString(XContentBuilder.defaultDatePrinter.print(((java.sql.Date) value).getTime())); } else { gen.writeString(value.toString()); }