Dealing with date types in Java API

Hi there,

I am dealing with the Java API and have a problem getting a Date object

For the index /employees/employee I have a mapping for the employed_since
field like:

"employed_since": {
"type": "date",
"format": "dateOptionalTime"
The document has of course some more fields :slight_smile:

With the Java-API I created a node and I'll issue a:

GetResponse object = client.prepareGet("employees", "employee",
"SOME_ID").setFields("employed_since", "name", "first_name", "gender"

When I now try to access object.getField("employed_since").getValue() I
receive the String representation of the Date object.

of course I could parse the string, but what is the best practice here? How
do I get the Date object back without having to parse it?

Thanks for any help!


You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
For more options, visit

Has anyone responded to your initial post...I know that it has been an few years

I am running into this same issue and wanted to know if there was like a unmarshall like functionality I can hook into that will convert the String Date into an actual Date object.

I will also try to re-post in case.