Skip to content

Commit

Permalink
Support Date / Timestamp objects (elastic#934)
Browse files Browse the repository at this point in the history
Added support for handling Date and Timestamp objects - convert to epoch milliseconds
  • Loading branch information
dmarkhas authored and jbaiera committed May 10, 2017
1 parent c0c963b commit b7f89a8
Showing 1 changed file with 8 additions and 1 deletion.
Expand Up @@ -20,6 +20,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Date;
import java.util.concurrent.Callable;

import org.apache.commons.logging.Log;
Expand Down Expand Up @@ -120,6 +121,12 @@ void doWrite(Object value) {

pool.get().bytes(valueString);
}

else if (value instanceof Date) {
String valueString = (value == null ? "null": Long.toString(((Date) value).getTime()));
pool.get().bytes(valueString);
}

else if (value instanceof RawJson) {
pool.get().bytes(((RawJson) value).json());
}
Expand Down Expand Up @@ -431,4 +438,4 @@ private List<Object> compact(List<Object> list) {
protected FieldExtractor getParamExtractor() {
return paramsExtractor;
}
}
}

0 comments on commit b7f89a8

Please sign in to comment.