Convert float to int in a scripted field

Hi,

using Kibana 5.4.1

My documents have 2 date-type fields: "starttime" and "endtime". I am trying to create a scripted field with the difference, in hours.
In the script box, I have this

(doc['endtime'].value - doc['starttime'].value)/3600

but it gives me the result as a float. For example: 24.000
How can I cast it to an integer? I don't find a clear clue in the documentation...

Are these actual date type fields in Elasticsearch? If so, this doc page will provide you with a lot of information about working with dates in Painless scripts.

indeed they are.
I had a look before to that page, and I didn't see anything clear that can help me. I will try again, maybe I missed it... :stuck_out_tongue:

Try this:

def start = doc['starttime'].value;
def end = doc['endtime'].value;
return ChronoUnit.HOURS.between(start, end);

AFK.
I will try that, and I will provide for feedback.

In any case, even if that resolves this particular case, the question is more general: how to cast a float to int.

Hmmm. Everything seems to be a little bit of a confusion. The output I got -24,000- was not a float. Apparently it is an integer, 24000. It seems like doc['foo'].value returns milliseconds.
I guess I got confused with the format for decimals (dot vs comma).