*** Just saw you are on version 6.8 and I am not sure it contains the library below on that far back of a version. But will leave the answer here since it applies to newer versions.
I would use the datetime API to do anything with dates. Here is how do to do difference between dates.
Something like the below. I did miliseconds but you can choose a different unit.
ZonedDateTime end = ZonedDateTime.parse(doc['end_time'].value);
ZonedDateTime start = ZonedDateTime.parse(doc['start_time'].value);
long differenceInMillis = ChronoUnit.MILLIS.between(start, end);
return differenceInMillis;
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.