-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Closed
Labels
:Core/Infra/ScriptingScripting abstractions, Painless, and MustacheScripting abstractions, Painless, and Mustache>feature
Description
Describe the feature:
A little context : I am trying to compute the difference in months between two dates in a scripted field.
I want to use the ChronoUnit.MONTHS.between() methods, which takes Java 8 date objects as parameters. But when getting dates from my document, I get JodaTime ReadableDateTime objects.
So I'm using the following to convert between JodaTime date object and Java 8 date objects :
var date = doc['subscribed_at'].value
Instant.ofEpochMilli(date.getMillis()).atZone(ZoneId.of(date.getZone().getID()))
However, according to the Painless API reference, getZone() is not whilelisted, which prevents me from converting the time properly by taking the timezone into account.
So, would it be possible to whitelist the getZone() method?
Or maybe I am missing something and there is a simpler way to do what I'm trying to do?
Metadata
Metadata
Assignees
Labels
:Core/Infra/ScriptingScripting abstractions, Painless, and MustacheScripting abstractions, Painless, and Mustache>feature