You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
The timezone of the date will always be UTC (+0), as that is what it is set to when constructing the ReadableDateTime object. Additionally, we are moving away from joda time altogether, and replacing with java time (this should be available to use in the scripting api in 6.4.0, see #31441). Since we are trying to remove joda time, I don't think we should add any more whitelisted methods, and thus I am going to close this issue.
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 :
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?
The text was updated successfully, but these errors were encountered: