Hi guys,
Out of the box, Elastic allows us to perform an aggregation as following:
"inline": "doc['LAST_MODIFIED_DATE'].date.getWeekOfWeekyear()"
Which is great! However, our system here supports time zone. That also is normally covered by using the ZonedDateDime, ie:
ZonedDateTime.ofInstant(Instant.ofEpochMilli(doc['LAST_MODIFIED_DATE'].value), ZoneId.of('UTC'))
So far, so good.
The problem I'm facing is, after getting the zoned datetime I cannot invoke the 'getWeekOfWeekyear()' method as it can only be accessed MutableDateTime (and other classes) but not by a ZonedDateTime object.
I've tried to create an instance a MutableDateTime obj, but it's not recognized. I've tried the following workarounds as well:
Instant instant = ZonedDateTime.ofInstant(Instant.ofEpochMilli(doc['LAST_MODIFIED_DATE'].value), ZoneId.of('UTC')).toInstant();
Date date = Date.from(instant);
date.getWeekOfWeekyear()
def dateCopy = doc['LAST_MODIFIED_DATE'].date;
Instant instant = ZonedDateTime.ofInstant(Instant.ofEpochMilli(doc['LAST_MODIFIED_DATE'].value), ZoneId.of('UTC')).toInstant();
dateCopy = new MutableDateTime(instant);
dateCopy.getWeekOfWeekyear()
It seems so close, but I couldn't sort that out yet.
Any guru could help me w/ that?
Cheers!