elasticsearch/elasticsearch — Issue #1465: XContentBuilder and more consistent handling of Dates
Author: dawi
Created: 2011-11-14 19:06:59+00:00
State: open

class: org.elasticsearch.common.xcontent.XContentBuilder
method: field(String name, Object value)

```java
} else if (type == Byte.class) {
field(name, ((Byte) value).byteValue());
} else if (type == Boolean.class) {
field(name, ((Boolean) value).booleanValue());
} else if (type == Date.class) {
field(name, (Date) value);
} else if (type == byte[].class) {
```

While it is ok to use ```type == xxx.class``` for final java classes I don't think it should be used for Date. Instead ```instanceof``` should be used so that the following method calls behave the same:

```java
xContentBuilder.field(field, (Date) dateValue)
xContentBuilder.field(field, (Object) dateValue)
```